Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Kirill Smelkov
cpython
Commits
b0f5adc3
"README" did not exist on "af64aff9f7de2ee60c20bfb331e8a00ea0521c1e"
Commit
b0f5adc3
authored
15 years ago
by
Ezio Melotti
Browse files
Options
Download
Email Patches
Plain Diff
use assert[Not]IsInstance where appropriate
parent
f14c7fc3
Changes
57
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
104 additions
and
105 deletions
+104
-105
Lib/test/mapping_tests.py
Lib/test/mapping_tests.py
+3
-3
Lib/test/test_abc.py
Lib/test/test_abc.py
+12
-12
Lib/test/test_array.py
Lib/test/test_array.py
+3
-3
Lib/test/test_ast.py
Lib/test/test_ast.py
+1
-1
Lib/test/test_augassign.py
Lib/test/test_augassign.py
+2
-2
Lib/test/test_bool.py
Lib/test/test_bool.py
+3
-3
Lib/test/test_bytes.py
Lib/test/test_bytes.py
+1
-1
Lib/test/test_codecs.py
Lib/test/test_codecs.py
+2
-2
Lib/test/test_collections.py
Lib/test/test_collections.py
+24
-24
Lib/test/test_compile.py
Lib/test/test_compile.py
+3
-3
Lib/test/test_compiler.py
Lib/test/test_compiler.py
+1
-1
Lib/test/test_cookielib.py
Lib/test/test_cookielib.py
+1
-1
Lib/test/test_datetime.py
Lib/test/test_datetime.py
+15
-16
Lib/test/test_decimal.py
Lib/test/test_decimal.py
+2
-2
Lib/test/test_descr.py
Lib/test/test_descr.py
+13
-13
Lib/test/test_dict.py
Lib/test/test_dict.py
+1
-1
Lib/test/test_dictviews.py
Lib/test/test_dictviews.py
+4
-4
Lib/test/test_dummy_thread.py
Lib/test/test_dummy_thread.py
+5
-5
Lib/test/test_ftplib.py
Lib/test/test_ftplib.py
+7
-7
Lib/test/test_funcattrs.py
Lib/test/test_funcattrs.py
+1
-1
No files found.
Lib/test/mapping_tests.py
View file @
b0f5adc3
...
@@ -451,7 +451,7 @@ class TestMappingProtocol(BasicTestMappingProtocol):
...
@@ -451,7 +451,7 @@ class TestMappingProtocol(BasicTestMappingProtocol):
ud
=
mydict
.
fromkeys
(
'ab'
)
ud
=
mydict
.
fromkeys
(
'ab'
)
self
.
assertEqual
(
ud
,
{
'a'
:
None
,
'b'
:
None
})
self
.
assertEqual
(
ud
,
{
'a'
:
None
,
'b'
:
None
})
# FIXME: the following won't work with UserDict, because it's an old style class
# FIXME: the following won't work with UserDict, because it's an old style class
# self.assert
True(isi
nstance(ud, UserDict.UserDict)
)
# self.assert
IsI
nstance(ud, UserDict.UserDict)
self
.
assertRaises
(
TypeError
,
dict
.
fromkeys
)
self
.
assertRaises
(
TypeError
,
dict
.
fromkeys
)
class
Exc
(
Exception
):
pass
class
Exc
(
Exception
):
pass
...
@@ -481,7 +481,7 @@ class TestMappingProtocol(BasicTestMappingProtocol):
...
@@ -481,7 +481,7 @@ class TestMappingProtocol(BasicTestMappingProtocol):
self
.
assertEqual
(
d
.
copy
(),
{
1
:
1
,
2
:
2
,
3
:
3
})
self
.
assertEqual
(
d
.
copy
(),
{
1
:
1
,
2
:
2
,
3
:
3
})
d
=
self
.
_empty_mapping
()
d
=
self
.
_empty_mapping
()
self
.
assertEqual
(
d
.
copy
(),
d
)
self
.
assertEqual
(
d
.
copy
(),
d
)
self
.
assert
True
(
isi
nstance
(
d
.
copy
(),
d
.
__class__
)
)
self
.
assert
IsI
nstance
(
d
.
copy
(),
d
.
__class__
)
self
.
assertRaises
(
TypeError
,
d
.
copy
,
None
)
self
.
assertRaises
(
TypeError
,
d
.
copy
,
None
)
def
test_get
(
self
):
def
test_get
(
self
):
...
@@ -586,7 +586,7 @@ class TestHashMappingProtocol(TestMappingProtocol):
...
@@ -586,7 +586,7 @@ class TestHashMappingProtocol(TestMappingProtocol):
return
UserDict
.
UserDict
()
return
UserDict
.
UserDict
()
ud
=
mydict
.
fromkeys
(
'ab'
)
ud
=
mydict
.
fromkeys
(
'ab'
)
self
.
assertEqual
(
ud
,
{
'a'
:
None
,
'b'
:
None
})
self
.
assertEqual
(
ud
,
{
'a'
:
None
,
'b'
:
None
})
self
.
assert
True
(
isi
nstance
(
ud
,
UserDict
.
UserDict
)
)
self
.
assert
IsI
nstance
(
ud
,
UserDict
.
UserDict
)
def
test_pop
(
self
):
def
test_pop
(
self
):
TestMappingProtocol
.
test_pop
(
self
)
TestMappingProtocol
.
test_pop
(
self
)
...
...
This diff is collapsed.
Click to expand it.
Lib/test/test_abc.py
View file @
b0f5adc3
...
@@ -89,20 +89,20 @@ class TestABC(unittest.TestCase):
...
@@ -89,20 +89,20 @@ class TestABC(unittest.TestCase):
b
=
B
()
b
=
B
()
self
.
assertEqual
(
issubclass
(
B
,
A
),
False
)
self
.
assertEqual
(
issubclass
(
B
,
A
),
False
)
self
.
assertEqual
(
issubclass
(
B
,
(
A
,)),
False
)
self
.
assertEqual
(
issubclass
(
B
,
(
A
,)),
False
)
self
.
assert
Equal
(
isi
nstance
(
b
,
A
)
,
False
)
self
.
assert
NotIsI
nstance
(
b
,
A
)
self
.
assert
Equal
(
isi
nstance
(
b
,
(
A
,))
,
False
)
self
.
assert
NotIsI
nstance
(
b
,
(
A
,))
A
.
register
(
B
)
A
.
register
(
B
)
self
.
assertEqual
(
issubclass
(
B
,
A
),
True
)
self
.
assertEqual
(
issubclass
(
B
,
A
),
True
)
self
.
assertEqual
(
issubclass
(
B
,
(
A
,)),
True
)
self
.
assertEqual
(
issubclass
(
B
,
(
A
,)),
True
)
self
.
assert
Equal
(
isi
nstance
(
b
,
A
)
,
True
)
self
.
assert
IsI
nstance
(
b
,
A
)
self
.
assert
Equal
(
isi
nstance
(
b
,
(
A
,))
,
True
)
self
.
assert
IsI
nstance
(
b
,
(
A
,))
class
C
(
B
):
class
C
(
B
):
pass
pass
c
=
C
()
c
=
C
()
self
.
assertEqual
(
issubclass
(
C
,
A
),
True
)
self
.
assertEqual
(
issubclass
(
C
,
A
),
True
)
self
.
assertEqual
(
issubclass
(
C
,
(
A
,)),
True
)
self
.
assertEqual
(
issubclass
(
C
,
(
A
,)),
True
)
self
.
assert
Equal
(
isi
nstance
(
c
,
A
)
,
True
)
self
.
assert
IsI
nstance
(
c
,
A
)
self
.
assert
Equal
(
isi
nstance
(
c
,
(
A
,))
,
True
)
self
.
assert
IsI
nstance
(
c
,
(
A
,))
def
test_isinstance_invalidation
(
self
):
def
test_isinstance_invalidation
(
self
):
class
A
:
class
A
:
...
@@ -120,15 +120,15 @@ class TestABC(unittest.TestCase):
...
@@ -120,15 +120,15 @@ class TestABC(unittest.TestCase):
class
A
:
class
A
:
__metaclass__
=
abc
.
ABCMeta
__metaclass__
=
abc
.
ABCMeta
A
.
register
(
int
)
A
.
register
(
int
)
self
.
assert
Equal
(
isi
nstance
(
42
,
A
)
,
True
)
self
.
assert
IsI
nstance
(
42
,
A
)
self
.
assert
Equal
(
isi
nstance
(
42
,
(
A
,))
,
True
)
self
.
assert
IsI
nstance
(
42
,
(
A
,))
self
.
assertEqual
(
issubclass
(
int
,
A
),
True
)
self
.
assertEqual
(
issubclass
(
int
,
A
),
True
)
self
.
assertEqual
(
issubclass
(
int
,
(
A
,)),
True
)
self
.
assertEqual
(
issubclass
(
int
,
(
A
,)),
True
)
class
B
(
A
):
class
B
(
A
):
pass
pass
B
.
register
(
basestring
)
B
.
register
(
basestring
)
self
.
assert
Equal
(
isi
nstance
(
""
,
A
)
,
True
)
self
.
assert
IsI
nstance
(
""
,
A
)
self
.
assert
Equal
(
isi
nstance
(
""
,
(
A
,))
,
True
)
self
.
assert
IsI
nstance
(
""
,
(
A
,))
self
.
assertEqual
(
issubclass
(
str
,
A
),
True
)
self
.
assertEqual
(
issubclass
(
str
,
A
),
True
)
self
.
assertEqual
(
issubclass
(
str
,
(
A
,)),
True
)
self
.
assertEqual
(
issubclass
(
str
,
(
A
,)),
True
)
...
@@ -185,8 +185,8 @@ class TestABC(unittest.TestCase):
...
@@ -185,8 +185,8 @@ class TestABC(unittest.TestCase):
pass
pass
self
.
assertTrue
(
issubclass
(
MyInt
,
A
))
self
.
assertTrue
(
issubclass
(
MyInt
,
A
))
self
.
assertTrue
(
issubclass
(
MyInt
,
(
A
,)))
self
.
assertTrue
(
issubclass
(
MyInt
,
(
A
,)))
self
.
assert
True
(
isi
nstance
(
42
,
A
)
)
self
.
assert
IsI
nstance
(
42
,
A
)
self
.
assert
True
(
isi
nstance
(
42
,
(
A
,))
)
self
.
assert
IsI
nstance
(
42
,
(
A
,))
def
test_all_new_methods_are_called
(
self
):
def
test_all_new_methods_are_called
(
self
):
class
A
:
class
A
:
...
...
This diff is collapsed.
Click to expand it.
Lib/test/test_array.py
View file @
b0f5adc3
...
@@ -63,10 +63,10 @@ class BaseTest(unittest.TestCase):
...
@@ -63,10 +63,10 @@ class BaseTest(unittest.TestCase):
a
=
array
.
array
(
self
.
typecode
,
self
.
example
)
a
=
array
.
array
(
self
.
typecode
,
self
.
example
)
self
.
assertRaises
(
TypeError
,
a
.
buffer_info
,
42
)
self
.
assertRaises
(
TypeError
,
a
.
buffer_info
,
42
)
bi
=
a
.
buffer_info
()
bi
=
a
.
buffer_info
()
self
.
assert
True
(
isi
nstance
(
bi
,
tuple
)
)
self
.
assert
IsI
nstance
(
bi
,
tuple
)
self
.
assertEqual
(
len
(
bi
),
2
)
self
.
assertEqual
(
len
(
bi
),
2
)
self
.
assert
True
(
isi
nstance
(
bi
[
0
],
(
int
,
long
))
)
self
.
assert
IsI
nstance
(
bi
[
0
],
(
int
,
long
))
self
.
assert
True
(
isi
nstance
(
bi
[
1
],
int
)
)
self
.
assert
IsI
nstance
(
bi
[
1
],
int
)
self
.
assertEqual
(
bi
[
1
],
len
(
a
))
self
.
assertEqual
(
bi
[
1
],
len
(
a
))
def
test_byteswap
(
self
):
def
test_byteswap
(
self
):
...
...
This diff is collapsed.
Click to expand it.
Lib/test/test_ast.py
View file @
b0f5adc3
...
@@ -154,7 +154,7 @@ class AST_Tests(unittest.TestCase):
...
@@ -154,7 +154,7 @@ class AST_Tests(unittest.TestCase):
slc
=
ast
.
parse
(
"x[::]"
).
body
[
0
].
value
.
slice
slc
=
ast
.
parse
(
"x[::]"
).
body
[
0
].
value
.
slice
self
.
assertIsNone
(
slc
.
upper
)
self
.
assertIsNone
(
slc
.
upper
)
self
.
assertIsNone
(
slc
.
lower
)
self
.
assertIsNone
(
slc
.
lower
)
self
.
assert
True
(
isi
nstance
(
slc
.
step
,
ast
.
Name
)
)
self
.
assert
IsI
nstance
(
slc
.
step
,
ast
.
Name
)
self
.
assertEqual
(
slc
.
step
.
id
,
"None"
)
self
.
assertEqual
(
slc
.
step
.
id
,
"None"
)
def
test_from_import
(
self
):
def
test_from_import
(
self
):
...
...
This diff is collapsed.
Click to expand it.
Lib/test/test_augassign.py
View file @
b0f5adc3
...
@@ -99,7 +99,7 @@ class AugAssignTest(unittest.TestCase):
...
@@ -99,7 +99,7 @@ class AugAssignTest(unittest.TestCase):
y
=
x
y
=
x
x
+=
10
x
+=
10
self
.
assert
True
(
isi
nstance
(
x
,
aug_test
)
)
self
.
assert
IsI
nstance
(
x
,
aug_test
)
self
.
assertTrue
(
y
is
not
x
)
self
.
assertTrue
(
y
is
not
x
)
self
.
assertEquals
(
x
.
val
,
11
)
self
.
assertEquals
(
x
.
val
,
11
)
...
@@ -114,7 +114,7 @@ class AugAssignTest(unittest.TestCase):
...
@@ -114,7 +114,7 @@ class AugAssignTest(unittest.TestCase):
y
=
x
y
=
x
x
+=
10
x
+=
10
self
.
assert
True
(
isi
nstance
(
x
,
aug_test3
)
)
self
.
assert
IsI
nstance
(
x
,
aug_test3
)
self
.
assertTrue
(
y
is
not
x
)
self
.
assertTrue
(
y
is
not
x
)
self
.
assertEquals
(
x
.
val
,
13
)
self
.
assertEquals
(
x
.
val
,
13
)
...
...
This diff is collapsed.
Click to expand it.
Lib/test/test_bool.py
View file @
b0f5adc3
...
@@ -233,15 +233,15 @@ class BoolTest(unittest.TestCase):
...
@@ -233,15 +233,15 @@ class BoolTest(unittest.TestCase):
def
test_boolean
(
self
):
def
test_boolean
(
self
):
self
.
assertEqual
(
True
&
1
,
1
)
self
.
assertEqual
(
True
&
1
,
1
)
self
.
assert
True
(
not
isi
nstance
(
True
&
1
,
bool
)
)
self
.
assert
NotIsI
nstance
(
True
&
1
,
bool
)
self
.
assertIs
(
True
&
True
,
True
)
self
.
assertIs
(
True
&
True
,
True
)
self
.
assertEqual
(
True
|
1
,
1
)
self
.
assertEqual
(
True
|
1
,
1
)
self
.
assert
True
(
not
isi
nstance
(
True
|
1
,
bool
)
)
self
.
assert
NotIsI
nstance
(
True
|
1
,
bool
)
self
.
assertIs
(
True
|
True
,
True
)
self
.
assertIs
(
True
|
True
,
True
)
self
.
assertEqual
(
True
^
1
,
0
)
self
.
assertEqual
(
True
^
1
,
0
)
self
.
assert
True
(
not
isi
nstance
(
True
^
1
,
bool
)
)
self
.
assert
NotIsI
nstance
(
True
^
1
,
bool
)
self
.
assertIs
(
True
^
True
,
False
)
self
.
assertIs
(
True
^
True
,
False
)
def
test_fileclosed
(
self
):
def
test_fileclosed
(
self
):
...
...
This diff is collapsed.
Click to expand it.
Lib/test/test_bytes.py
View file @
b0f5adc3
...
@@ -970,7 +970,7 @@ class ByteArraySubclassTest(unittest.TestCase):
...
@@ -970,7 +970,7 @@ class ByteArraySubclassTest(unittest.TestCase):
def
test_basic
(
self
):
def
test_basic
(
self
):
self
.
assertTrue
(
issubclass
(
ByteArraySubclass
,
bytearray
))
self
.
assertTrue
(
issubclass
(
ByteArraySubclass
,
bytearray
))
self
.
assert
True
(
isi
nstance
(
ByteArraySubclass
(),
bytearray
)
)
self
.
assert
IsI
nstance
(
ByteArraySubclass
(),
bytearray
)
a
,
b
=
b
"abcd"
,
b
"efgh"
a
,
b
=
b
"abcd"
,
b
"efgh"
_a
,
_b
=
ByteArraySubclass
(
a
),
ByteArraySubclass
(
b
)
_a
,
_b
=
ByteArraySubclass
(
a
),
ByteArraySubclass
(
b
)
...
...
This diff is collapsed.
Click to expand it.
Lib/test/test_codecs.py
View file @
b0f5adc3
...
@@ -1141,14 +1141,14 @@ class Str2StrTest(unittest.TestCase):
...
@@ -1141,14 +1141,14 @@ class Str2StrTest(unittest.TestCase):
reader
=
codecs
.
getreader
(
"base64_codec"
)(
StringIO
.
StringIO
(
sin
))
reader
=
codecs
.
getreader
(
"base64_codec"
)(
StringIO
.
StringIO
(
sin
))
sout
=
reader
.
read
()
sout
=
reader
.
read
()
self
.
assertEqual
(
sout
,
"
\x80
"
)
self
.
assertEqual
(
sout
,
"
\x80
"
)
self
.
assert
True
(
isi
nstance
(
sout
,
str
)
)
self
.
assert
IsI
nstance
(
sout
,
str
)
def
test_readline
(
self
):
def
test_readline
(
self
):
sin
=
"
\x80
"
.
encode
(
"base64_codec"
)
sin
=
"
\x80
"
.
encode
(
"base64_codec"
)
reader
=
codecs
.
getreader
(
"base64_codec"
)(
StringIO
.
StringIO
(
sin
))
reader
=
codecs
.
getreader
(
"base64_codec"
)(
StringIO
.
StringIO
(
sin
))
sout
=
reader
.
readline
()
sout
=
reader
.
readline
()
self
.
assertEqual
(
sout
,
"
\x80
"
)
self
.
assertEqual
(
sout
,
"
\x80
"
)
self
.
assert
True
(
isi
nstance
(
sout
,
str
)
)
self
.
assert
IsI
nstance
(
sout
,
str
)
all_unicode_encodings
=
[
all_unicode_encodings
=
[
"ascii"
,
"ascii"
,
...
...
This diff is collapsed.
Click to expand it.
Lib/test/test_collections.py
View file @
b0f5adc3
...
@@ -101,7 +101,7 @@ class TestNamedTuple(unittest.TestCase):
...
@@ -101,7 +101,7 @@ class TestNamedTuple(unittest.TestCase):
Point
=
namedtuple
(
'Point'
,
'x y'
)
Point
=
namedtuple
(
'Point'
,
'x y'
)
p
=
Point
(
11
,
22
)
p
=
Point
(
11
,
22
)
self
.
assert
True
(
isi
nstance
(
p
,
tuple
)
)
self
.
assert
IsI
nstance
(
p
,
tuple
)
self
.
assertEqual
(
p
,
(
11
,
22
))
# matches a real tuple
self
.
assertEqual
(
p
,
(
11
,
22
))
# matches a real tuple
self
.
assertEqual
(
tuple
(
p
),
(
11
,
22
))
# coercable to a real tuple
self
.
assertEqual
(
tuple
(
p
),
(
11
,
22
))
# coercable to a real tuple
self
.
assertEqual
(
list
(
p
),
[
11
,
22
])
# coercable to a list
self
.
assertEqual
(
list
(
p
),
[
11
,
22
])
# coercable to a list
...
@@ -233,7 +233,7 @@ class TestOneTrickPonyABCs(ABCTestCase):
...
@@ -233,7 +233,7 @@ class TestOneTrickPonyABCs(ABCTestCase):
# Check some non-hashables
# Check some non-hashables
non_samples
=
[
list
(),
set
(),
dict
()]
non_samples
=
[
list
(),
set
(),
dict
()]
for
x
in
non_samples
:
for
x
in
non_samples
:
self
.
assert
False
(
isi
nstance
(
x
,
Hashable
)
,
repr
(
x
))
self
.
assert
NotIsI
nstance
(
x
,
Hashable
)
self
.
assertFalse
(
issubclass
(
type
(
x
),
Hashable
),
repr
(
type
(
x
)))
self
.
assertFalse
(
issubclass
(
type
(
x
),
Hashable
),
repr
(
type
(
x
)))
# Check some hashables
# Check some hashables
samples
=
[
None
,
samples
=
[
None
,
...
@@ -243,7 +243,7 @@ class TestOneTrickPonyABCs(ABCTestCase):
...
@@ -243,7 +243,7 @@ class TestOneTrickPonyABCs(ABCTestCase):
int
,
list
,
object
,
type
,
int
,
list
,
object
,
type
,
]
]
for
x
in
samples
:
for
x
in
samples
:
self
.
assert
True
(
isi
nstance
(
x
,
Hashable
)
,
repr
(
x
))
self
.
assert
IsI
nstance
(
x
,
Hashable
)
self
.
assertTrue
(
issubclass
(
type
(
x
),
Hashable
),
repr
(
type
(
x
)))
self
.
assertTrue
(
issubclass
(
type
(
x
),
Hashable
),
repr
(
type
(
x
)))
self
.
assertRaises
(
TypeError
,
Hashable
)
self
.
assertRaises
(
TypeError
,
Hashable
)
# Check direct subclassing
# Check direct subclassing
...
@@ -259,7 +259,7 @@ class TestOneTrickPonyABCs(ABCTestCase):
...
@@ -259,7 +259,7 @@ class TestOneTrickPonyABCs(ABCTestCase):
# Check some non-iterables
# Check some non-iterables
non_samples
=
[
None
,
42
,
3.14
,
1j
]
non_samples
=
[
None
,
42
,
3.14
,
1j
]
for
x
in
non_samples
:
for
x
in
non_samples
:
self
.
assert
False
(
isi
nstance
(
x
,
Iterable
)
,
repr
(
x
))
self
.
assert
NotIsI
nstance
(
x
,
Iterable
)
self
.
assertFalse
(
issubclass
(
type
(
x
),
Iterable
),
repr
(
type
(
x
)))
self
.
assertFalse
(
issubclass
(
type
(
x
),
Iterable
),
repr
(
type
(
x
)))
# Check some iterables
# Check some iterables
samples
=
[
str
(),
samples
=
[
str
(),
...
@@ -269,7 +269,7 @@ class TestOneTrickPonyABCs(ABCTestCase):
...
@@ -269,7 +269,7 @@ class TestOneTrickPonyABCs(ABCTestCase):
(
x
for
x
in
[]),
(
x
for
x
in
[]),
]
]
for
x
in
samples
:
for
x
in
samples
:
self
.
assert
True
(
isi
nstance
(
x
,
Iterable
)
,
repr
(
x
))
self
.
assert
IsI
nstance
(
x
,
Iterable
)
self
.
assertTrue
(
issubclass
(
type
(
x
),
Iterable
),
repr
(
type
(
x
)))
self
.
assertTrue
(
issubclass
(
type
(
x
),
Iterable
),
repr
(
type
(
x
)))
# Check direct subclassing
# Check direct subclassing
class
I
(
Iterable
):
class
I
(
Iterable
):
...
@@ -283,7 +283,7 @@ class TestOneTrickPonyABCs(ABCTestCase):
...
@@ -283,7 +283,7 @@ class TestOneTrickPonyABCs(ABCTestCase):
non_samples
=
[
None
,
42
,
3.14
,
1j
,
""
.
encode
(
'ascii'
),
""
,
(),
[],
non_samples
=
[
None
,
42
,
3.14
,
1j
,
""
.
encode
(
'ascii'
),
""
,
(),
[],
{},
set
()]
{},
set
()]
for
x
in
non_samples
:
for
x
in
non_samples
:
self
.
assert
False
(
isi
nstance
(
x
,
Iterator
)
,
repr
(
x
))
self
.
assert
NotIsI
nstance
(
x
,
Iterator
)
self
.
assertFalse
(
issubclass
(
type
(
x
),
Iterator
),
repr
(
type
(
x
)))
self
.
assertFalse
(
issubclass
(
type
(
x
),
Iterator
),
repr
(
type
(
x
)))
samples
=
[
iter
(
str
()),
samples
=
[
iter
(
str
()),
iter
(
tuple
()),
iter
(
list
()),
iter
(
dict
()),
iter
(
tuple
()),
iter
(
list
()),
iter
(
dict
()),
...
@@ -294,7 +294,7 @@ class TestOneTrickPonyABCs(ABCTestCase):
...
@@ -294,7 +294,7 @@ class TestOneTrickPonyABCs(ABCTestCase):
(
x
for
x
in
[]),
(
x
for
x
in
[]),
]
]
for
x
in
samples
:
for
x
in
samples
:
self
.
assert
True
(
isi
nstance
(
x
,
Iterator
)
,
repr
(
x
))
self
.
assert
IsI
nstance
(
x
,
Iterator
)
self
.
assertTrue
(
issubclass
(
type
(
x
),
Iterator
),
repr
(
type
(
x
)))
self
.
assertTrue
(
issubclass
(
type
(
x
),
Iterator
),
repr
(
type
(
x
)))
self
.
validate_abstract_methods
(
Iterator
,
'next'
)
self
.
validate_abstract_methods
(
Iterator
,
'next'
)
...
@@ -304,14 +304,14 @@ class TestOneTrickPonyABCs(ABCTestCase):
...
@@ -304,14 +304,14 @@ class TestOneTrickPonyABCs(ABCTestCase):
(
x
for
x
in
[]),
(
x
for
x
in
[]),
]
]
for
x
in
non_samples
:
for
x
in
non_samples
:
self
.
assert
False
(
isi
nstance
(
x
,
Sized
)
,
repr
(
x
))
self
.
assert
NotIsI
nstance
(
x
,
Sized
)
self
.
assertFalse
(
issubclass
(
type
(
x
),
Sized
),
repr
(
type
(
x
)))
self
.
assertFalse
(
issubclass
(
type
(
x
),
Sized
),
repr
(
type
(
x
)))
samples
=
[
str
(),
samples
=
[
str
(),
tuple
(),
list
(),
set
(),
frozenset
(),
dict
(),
tuple
(),
list
(),
set
(),
frozenset
(),
dict
(),
dict
().
keys
(),
dict
().
items
(),
dict
().
values
(),
dict
().
keys
(),
dict
().
items
(),
dict
().
values
(),
]
]
for
x
in
samples
:
for
x
in
samples
:
self
.
assert
True
(
isi
nstance
(
x
,
Sized
)
,
repr
(
x
))
self
.
assert
IsI
nstance
(
x
,
Sized
)
self
.
assertTrue
(
issubclass
(
type
(
x
),
Sized
),
repr
(
type
(
x
)))
self
.
assertTrue
(
issubclass
(
type
(
x
),
Sized
),
repr
(
type
(
x
)))
self
.
validate_abstract_methods
(
Sized
,
'__len__'
)
self
.
validate_abstract_methods
(
Sized
,
'__len__'
)
...
@@ -321,14 +321,14 @@ class TestOneTrickPonyABCs(ABCTestCase):
...
@@ -321,14 +321,14 @@ class TestOneTrickPonyABCs(ABCTestCase):
(
x
for
x
in
[]),
(
x
for
x
in
[]),
]
]
for
x
in
non_samples
:
for
x
in
non_samples
:
self
.
assert
False
(
isi
nstance
(
x
,
Container
)
,
repr
(
x
))
self
.
assert
NotIsI
nstance
(
x
,
Container
)
self
.
assertFalse
(
issubclass
(
type
(
x
),
Container
),
repr
(
type
(
x
)))
self
.
assertFalse
(
issubclass
(
type
(
x
),
Container
),
repr
(
type
(
x
)))
samples
=
[
str
(),
samples
=
[
str
(),
tuple
(),
list
(),
set
(),
frozenset
(),
dict
(),
tuple
(),
list
(),
set
(),
frozenset
(),
dict
(),
dict
().
keys
(),
dict
().
items
(),
dict
().
keys
(),
dict
().
items
(),
]
]
for
x
in
samples
:
for
x
in
samples
:
self
.
assert
True
(
isi
nstance
(
x
,
Container
)
,
repr
(
x
))
self
.
assert
IsI
nstance
(
x
,
Container
)
self
.
assertTrue
(
issubclass
(
type
(
x
),
Container
),
repr
(
type
(
x
)))
self
.
assertTrue
(
issubclass
(
type
(
x
),
Container
),
repr
(
type
(
x
)))
self
.
validate_abstract_methods
(
Container
,
'__contains__'
)
self
.
validate_abstract_methods
(
Container
,
'__contains__'
)
...
@@ -339,7 +339,7 @@ class TestOneTrickPonyABCs(ABCTestCase):
...
@@ -339,7 +339,7 @@ class TestOneTrickPonyABCs(ABCTestCase):
(
x
for
x
in
[]),
(
x
for
x
in
[]),
]
]
for
x
in
non_samples
:
for
x
in
non_samples
:
self
.
assert
False
(
isi
nstance
(
x
,
Callable
)
,
repr
(
x
))
self
.
assert
NotIsI
nstance
(
x
,
Callable
)
self
.
assertFalse
(
issubclass
(
type
(
x
),
Callable
),
repr
(
type
(
x
)))
self
.
assertFalse
(
issubclass
(
type
(
x
),
Callable
),
repr
(
type
(
x
)))
samples
=
[
lambda
:
None
,
samples
=
[
lambda
:
None
,
type
,
int
,
object
,
type
,
int
,
object
,
...
@@ -347,7 +347,7 @@ class TestOneTrickPonyABCs(ABCTestCase):
...
@@ -347,7 +347,7 @@ class TestOneTrickPonyABCs(ABCTestCase):
list
.
append
,
[].
append
,
list
.
append
,
[].
append
,
]
]
for
x
in
samples
:
for
x
in
samples
:
self
.
assert
True
(
isi
nstance
(
x
,
Callable
)
,
repr
(
x
))
self
.
assert
IsI
nstance
(
x
,
Callable
)
self
.
assertTrue
(
issubclass
(
type
(
x
),
Callable
),
repr
(
type
(
x
)))
self
.
assertTrue
(
issubclass
(
type
(
x
),
Callable
),
repr
(
type
(
x
)))
self
.
validate_abstract_methods
(
Callable
,
'__call__'
)
self
.
validate_abstract_methods
(
Callable
,
'__call__'
)
...
@@ -395,7 +395,7 @@ class TestCollectionABCs(ABCTestCase):
...
@@ -395,7 +395,7 @@ class TestCollectionABCs(ABCTestCase):
def
test_Set
(
self
):
def
test_Set
(
self
):
for
sample
in
[
set
,
frozenset
]:
for
sample
in
[
set
,
frozenset
]:
self
.
assert
True
(
isi
nstance
(
sample
(),
Set
)
)
self
.
assert
IsI
nstance
(
sample
(),
Set
)
self
.
assertTrue
(
issubclass
(
sample
,
Set
))
self
.
assertTrue
(
issubclass
(
sample
,
Set
))
self
.
validate_abstract_methods
(
Set
,
'__contains__'
,
'__iter__'
,
'__len__'
)
self
.
validate_abstract_methods
(
Set
,
'__contains__'
,
'__iter__'
,
'__len__'
)
...
@@ -415,9 +415,9 @@ class TestCollectionABCs(ABCTestCase):
...
@@ -415,9 +415,9 @@ class TestCollectionABCs(ABCTestCase):
self
.
assertTrue
(
hash
(
a
)
==
hash
(
b
))
self
.
assertTrue
(
hash
(
a
)
==
hash
(
b
))
def
test_MutableSet
(
self
):
def
test_MutableSet
(
self
):
self
.
assert
True
(
isi
nstance
(
set
(),
MutableSet
)
)
self
.
assert
IsI
nstance
(
set
(),
MutableSet
)
self
.
assertTrue
(
issubclass
(
set
,
MutableSet
))
self
.
assertTrue
(
issubclass
(
set
,
MutableSet
))
self
.
assert
False
(
isi
nstance
(
frozenset
(),
MutableSet
)
)
self
.
assert
NotIsI
nstance
(
frozenset
(),
MutableSet
)
self
.
assertFalse
(
issubclass
(
frozenset
,
MutableSet
))
self
.
assertFalse
(
issubclass
(
frozenset
,
MutableSet
))
self
.
validate_abstract_methods
(
MutableSet
,
'__contains__'
,
'__iter__'
,
'__len__'
,
self
.
validate_abstract_methods
(
MutableSet
,
'__contains__'
,
'__iter__'
,
'__len__'
,
'add'
,
'discard'
)
'add'
,
'discard'
)
...
@@ -457,24 +457,24 @@ class TestCollectionABCs(ABCTestCase):
...
@@ -457,24 +457,24 @@ class TestCollectionABCs(ABCTestCase):
def
test_Mapping
(
self
):
def
test_Mapping
(
self
):
for
sample
in
[
dict
]:
for
sample
in
[
dict
]:
self
.
assert
True
(
isi
nstance
(
sample
(),
Mapping
)
)
self
.
assert
IsI
nstance
(
sample
(),
Mapping
)
self
.
assertTrue
(
issubclass
(
sample
,
Mapping
))
self
.
assertTrue
(
issubclass
(
sample
,
Mapping
))
self
.
validate_abstract_methods
(
Mapping
,
'__contains__'
,
'__iter__'
,
'__len__'
,
self
.
validate_abstract_methods
(
Mapping
,
'__contains__'
,
'__iter__'
,
'__len__'
,
'__getitem__'
)
'__getitem__'
)
def
test_MutableMapping
(
self
):
def
test_MutableMapping
(
self
):
for
sample
in
[
dict
]:
for
sample
in
[
dict
]:
self
.
assert
True
(
isi
nstance
(
sample
(),
MutableMapping
)
)
self
.
assert
IsI
nstance
(
sample
(),
MutableMapping
)
self
.
assertTrue
(
issubclass
(
sample
,
MutableMapping
))
self
.
assertTrue
(
issubclass
(
sample
,
MutableMapping
))
self
.
validate_abstract_methods
(
MutableMapping
,
'__contains__'
,
'__iter__'
,
'__len__'
,
self
.
validate_abstract_methods
(
MutableMapping
,
'__contains__'
,
'__iter__'
,
'__len__'
,
'__getitem__'
,
'__setitem__'
,
'__delitem__'
)
'__getitem__'
,
'__setitem__'
,
'__delitem__'
)
def
test_Sequence
(
self
):
def
test_Sequence
(
self
):
for
sample
in
[
tuple
,
list
,
str
]:
for
sample
in
[
tuple
,
list
,
str
]:
self
.
assert
True
(
isi
nstance
(
sample
(),
Sequence
)
)
self
.
assert
IsI
nstance
(
sample
(),
Sequence
)
self
.
assertTrue
(
issubclass
(
sample
,
Sequence
))
self
.
assertTrue
(
issubclass
(
sample
,
Sequence
))
self
.
assertTrue
(
issubclass
(
basestring
,
Sequence
))
self
.
assertTrue
(
issubclass
(
basestring
,
Sequence
))
self
.
assert
True
(
isi
nstance
(
range
(
10
),
Sequence
)
)
self
.
assert
IsI
nstance
(
range
(
10
),
Sequence
)
self
.
assertTrue
(
issubclass
(
xrange
,
Sequence
))
self
.
assertTrue
(
issubclass
(
xrange
,
Sequence
))
self
.
assertTrue
(
issubclass
(
str
,
Sequence
))
self
.
assertTrue
(
issubclass
(
str
,
Sequence
))
self
.
validate_abstract_methods
(
Sequence
,
'__contains__'
,
'__iter__'
,
'__len__'
,
self
.
validate_abstract_methods
(
Sequence
,
'__contains__'
,
'__iter__'
,
'__len__'
,
...
@@ -482,10 +482,10 @@ class TestCollectionABCs(ABCTestCase):
...
@@ -482,10 +482,10 @@ class TestCollectionABCs(ABCTestCase):
def
test_MutableSequence
(
self
):
def
test_MutableSequence
(
self
):
for
sample
in
[
tuple
,
str
]:
for
sample
in
[
tuple
,
str
]:
self
.
assert
False
(
isi
nstance
(
sample
(),
MutableSequence
)
)
self
.
assert
NotIsI
nstance
(
sample
(),
MutableSequence
)
self
.
assertFalse
(
issubclass
(
sample
,
MutableSequence
))
self
.
assertFalse
(
issubclass
(
sample
,
MutableSequence
))
for
sample
in
[
list
]:
for
sample
in
[
list
]:
self
.
assert
True
(
isi
nstance
(
sample
(),
MutableSequence
)
)
self
.
assert
IsI
nstance
(
sample
(),
MutableSequence
)
self
.
assertTrue
(
issubclass
(
sample
,
MutableSequence
))
self
.
assertTrue
(
issubclass
(
sample
,
MutableSequence
))
self
.
assertFalse
(
issubclass
(
basestring
,
MutableSequence
))
self
.
assertFalse
(
issubclass
(
basestring
,
MutableSequence
))
self
.
validate_abstract_methods
(
MutableSequence
,
'__contains__'
,
'__iter__'
,
self
.
validate_abstract_methods
(
MutableSequence
,
'__contains__'
,
'__iter__'
,
...
@@ -497,8 +497,8 @@ class TestCounter(unittest.TestCase):
...
@@ -497,8 +497,8 @@ class TestCounter(unittest.TestCase):
c
=
Counter
(
'abcaba'
)
c
=
Counter
(
'abcaba'
)
self
.
assertEqual
(
c
,
Counter
({
'a'
:
3
,
'b'
:
2
,
'c'
:
1
}))
self
.
assertEqual
(
c
,
Counter
({
'a'
:
3
,
'b'
:
2
,
'c'
:
1
}))
self
.
assertEqual
(
c
,
Counter
(
a
=
3
,
b
=
2
,
c
=
1
))
self
.
assertEqual
(
c
,
Counter
(
a
=
3
,
b
=
2
,
c
=
1
))
self
.
assert
True
(
isi
nstance
(
c
,
dict
)
)
self
.
assert
IsI
nstance
(
c
,
dict
)
self
.
assert
True
(
isi
nstance
(
c
,
Mapping
)
)
self
.
assert
IsI
nstance
(
c
,
Mapping
)
self
.
assertTrue
(
issubclass
(
Counter
,
dict
))
self
.
assertTrue
(
issubclass
(
Counter
,
dict
))
self
.
assertTrue
(
issubclass
(
Counter
,
Mapping
))
self
.
assertTrue
(
issubclass
(
Counter
,
Mapping
))
self
.
assertEqual
(
len
(
c
),
3
)
self
.
assertEqual
(
len
(
c
),
3
)
...
...
This diff is collapsed.
Click to expand it.
Lib/test/test_compile.py
View file @
b0f5adc3
...
@@ -249,8 +249,8 @@ if 1:
...
@@ -249,8 +249,8 @@ if 1:
self
.
fail
(
"How many bits *does* this machine have???"
)
self
.
fail
(
"How many bits *does* this machine have???"
)
# Verify treatment of contant folding on -(sys.maxint+1)
# Verify treatment of contant folding on -(sys.maxint+1)
# i.e. -2147483648 on 32 bit platforms. Should return int, not long.
# i.e. -2147483648 on 32 bit platforms. Should return int, not long.
self
.
assert
True
(
isi
nstance
(
eval
(
"%s"
%
(
-
sys
.
maxint
-
1
)),
int
)
)
self
.
assert
IsI
nstance
(
eval
(
"%s"
%
(
-
sys
.
maxint
-
1
)),
int
)
self
.
assert
True
(
isi
nstance
(
eval
(
"%s"
%
(
-
sys
.
maxint
-
2
)),
long
)
)
self
.
assert
IsI
nstance
(
eval
(
"%s"
%
(
-
sys
.
maxint
-
2
)),
long
)
if
sys
.
maxint
==
9223372036854775807
:
if
sys
.
maxint
==
9223372036854775807
:
def
test_32_63_bit_values
(
self
):
def
test_32_63_bit_values
(
self
):
...
@@ -265,7 +265,7 @@ if 1:
...
@@ -265,7 +265,7 @@ if 1:
for
variable
in
self
.
test_32_63_bit_values
.
func_code
.
co_consts
:
for
variable
in
self
.
test_32_63_bit_values
.
func_code
.
co_consts
:
if
variable
is
not
None
:
if
variable
is
not
None
:
self
.
assert
True
(
isi
nstance
(
variable
,
int
)
)
self
.
assert
IsI
nstance
(
variable
,
int
)
def
test_sequence_unpacking_error
(
self
):
def
test_sequence_unpacking_error
(
self
):
# Verify sequence packing/unpacking with "or". SF bug #757818
# Verify sequence packing/unpacking with "or". SF bug #757818
...
...
This diff is collapsed.
Click to expand it.
Lib/test/test_compiler.py
View file @
b0f5adc3
...
@@ -110,7 +110,7 @@ class CompilerTest(unittest.TestCase):
...
@@ -110,7 +110,7 @@ class CompilerTest(unittest.TestCase):
def
_check_lineno
(
self
,
node
):
def
_check_lineno
(
self
,
node
):
if
not
node
.
__class__
in
NOLINENO
:
if
not
node
.
__class__
in
NOLINENO
:
self
.
assert
True
(
isi
nstance
(
node
.
lineno
,
int
)
,
self
.
assert
IsI
nstance
(
node
.
lineno
,
int
,
"lineno=%s on %s"
%
(
node
.
lineno
,
node
.
__class__
))
"lineno=%s on %s"
%
(
node
.
lineno
,
node
.
__class__
))
self
.
assertTrue
(
node
.
lineno
>
0
,
self
.
assertTrue
(
node
.
lineno
>
0
,
"lineno=%s on %s"
%
(
node
.
lineno
,
node
.
__class__
))
"lineno=%s on %s"
%
(
node
.
lineno
,
node
.
__class__
))
...
...
This diff is collapsed.
Click to expand it.
Lib/test/test_cookielib.py
View file @
b0f5adc3
...
@@ -1043,7 +1043,7 @@ class CookieTests(TestCase):
...
@@ -1043,7 +1043,7 @@ class CookieTests(TestCase):
for
i
in
range
(
4
):
for
i
in
range
(
4
):
i
=
0
i
=
0
for
c
in
cs
:
for
c
in
cs
:
self
.
assert
True
(
isi
nstance
(
c
,
Cookie
)
)
self
.
assert
IsI
nstance
(
c
,
Cookie
)
self
.
assertEquals
(
c
.
version
,
versions
[
i
])
self
.
assertEquals
(
c
.
version
,
versions
[
i
])
self
.
assertEquals
(
c
.
name
,
names
[
i
])
self
.
assertEquals
(
c
.
name
,
names
[
i
])
self
.
assertEquals
(
c
.
domain
,
domains
[
i
])
self
.
assertEquals
(
c
.
domain
,
domains
[
i
])
...
...
This diff is collapsed.
Click to expand it.
Lib/test/test_datetime.py
View file @
b0f5adc3
...
@@ -81,7 +81,7 @@ class TestTZInfo(unittest.TestCase):
...
@@ -81,7 +81,7 @@ class TestTZInfo(unittest.TestCase):
self
.
__name
=
name
self
.
__name
=
name
self
.
assertTrue
(
issubclass
(
NotEnough
,
tzinfo
))
self
.
assertTrue
(
issubclass
(
NotEnough
,
tzinfo
))
ne
=
NotEnough
(
3
,
"NotByALongShot"
)
ne
=
NotEnough
(
3
,
"NotByALongShot"
)
self
.
assert
True
(
isi
nstance
(
ne
,
tzinfo
)
)
self
.
assert
IsI
nstance
(
ne
,
tzinfo
)
dt
=
datetime
.
now
()
dt
=
datetime
.
now
()
self
.
assertRaises
(
NotImplementedError
,
ne
.
tzname
,
dt
)
self
.
assertRaises
(
NotImplementedError
,
ne
.
tzname
,
dt
)
...
@@ -90,7 +90,7 @@ class TestTZInfo(unittest.TestCase):
...
@@ -90,7 +90,7 @@ class TestTZInfo(unittest.TestCase):
def
test_normal
(
self
):
def
test_normal
(
self
):
fo
=
FixedOffset
(
3
,
"Three"
)
fo
=
FixedOffset
(
3
,
"Three"
)
self
.
assert
True
(
isi
nstance
(
fo
,
tzinfo
)
)
self
.
assert
IsI
nstance
(
fo
,
tzinfo
)
for
dt
in
datetime
.
now
(),
None
:
for
dt
in
datetime
.
now
(),
None
:
self
.
assertEqual
(
fo
.
utcoffset
(
dt
),
timedelta
(
minutes
=
3
))
self
.
assertEqual
(
fo
.
utcoffset
(
dt
),
timedelta
(
minutes
=
3
))
self
.
assertEqual
(
fo
.
tzname
(
dt
),
"Three"
)
self
.
assertEqual
(
fo
.
tzname
(
dt
),
"Three"
)
...
@@ -111,14 +111,14 @@ class TestTZInfo(unittest.TestCase):
...
@@ -111,14 +111,14 @@ class TestTZInfo(unittest.TestCase):
# Make sure we can pickle/unpickle an instance of a subclass.
# Make sure we can pickle/unpickle an instance of a subclass.
offset
=
timedelta
(
minutes
=-
300
)
offset
=
timedelta
(
minutes
=-
300
)
orig
=
PicklableFixedOffset
(
offset
,
'cookie'
)
orig
=
PicklableFixedOffset
(
offset
,
'cookie'
)
self
.
assert
True
(
isi
nstance
(
orig
,
tzinfo
)
)
self
.
assert
IsI
nstance
(
orig
,
tzinfo
)
self
.
assertTrue
(
type
(
orig
)
is
PicklableFixedOffset
)
self
.
assertTrue
(
type
(
orig
)
is
PicklableFixedOffset
)
self
.
assertEqual
(
orig
.
utcoffset
(
None
),
offset
)
self
.
assertEqual
(
orig
.
utcoffset
(
None
),
offset
)
self
.
assertEqual
(
orig
.
tzname
(
None
),
'cookie'
)
self
.
assertEqual
(
orig
.
tzname
(
None
),
'cookie'
)
for
pickler
,
unpickler
,
proto
in
pickle_choices
:
for
pickler
,
unpickler
,
proto
in
pickle_choices
:
green
=
pickler
.
dumps
(
orig
,
proto
)
green
=
pickler
.
dumps
(
orig
,
proto
)
derived
=
unpickler
.
loads
(
green
)
derived
=
unpickler
.
loads
(
green
)
self
.
assert
True
(
isi
nstance
(
derived
,
tzinfo
)
)
self
.
assert
IsI
nstance
(
derived
,
tzinfo
)
self
.
assertTrue
(
type
(
derived
)
is
PicklableFixedOffset
)
self
.
assertTrue
(
type
(
derived
)
is
PicklableFixedOffset
)
self
.
assertEqual
(
derived
.
utcoffset
(
None
),
offset
)
self
.
assertEqual
(
derived
.
utcoffset
(
None
),
offset
)
self
.
assertEqual
(
derived
.
tzname
(
None
),
'cookie'
)
self
.
assertEqual
(
derived
.
tzname
(
None
),
'cookie'
)
...
@@ -391,9 +391,9 @@ class TestTimeDelta(HarmlessMixedComparison, unittest.TestCase):
...
@@ -391,9 +391,9 @@ class TestTimeDelta(HarmlessMixedComparison, unittest.TestCase):
self
.
assertEqual
(
td
,
td2
)
self
.
assertEqual
(
td
,
td2
)
def
test_resolution_info
(
self
):
def
test_resolution_info
(
self
):
self
.
assert
True
(
isi
nstance
(
timedelta
.
min
,
timedelta
)
)
self
.
assert
IsI
nstance
(
timedelta
.
min
,
timedelta
)
self
.
assert
True
(
isi
nstance
(
timedelta
.
max
,
timedelta
)
)
self
.
assert
IsI
nstance
(
timedelta
.
max
,
timedelta
)
self
.
assert
True
(
isi
nstance
(
timedelta
.
resolution
,
timedelta
)
)
self
.
assert
IsI
nstance
(
timedelta
.
resolution
,
timedelta
)
self
.
assertTrue
(
timedelta
.
max
>
timedelta
.
min
)
self
.
assertTrue
(
timedelta
.
max
>
timedelta
.
min
)
self
.
assertEqual
(
timedelta
.
min
,
timedelta
(
-
999999999
))
self
.
assertEqual
(
timedelta
.
min
,
timedelta
(
-
999999999
))
self
.
assertEqual
(
timedelta
.
max
,
timedelta
(
999999999
,
24
*
3600
-
1
,
1e6
-
1
))
self
.
assertEqual
(
timedelta
.
max
,
timedelta
(
999999999
,
24
*
3600
-
1
,
1e6
-
1
))
...
@@ -905,9 +905,9 @@ class TestDate(HarmlessMixedComparison, unittest.TestCase):
...
@@ -905,9 +905,9 @@ class TestDate(HarmlessMixedComparison, unittest.TestCase):
self
.
assertEqual
(
b
.
__format__
(
fmt
),
'B'
)
self
.
assertEqual
(
b
.
__format__
(
fmt
),
'B'
)
def
test_resolution_info
(
self
):
def
test_resolution_info
(
self
):
self
.
assert
True
(
isi
nstance
(
self
.
theclass
.
min
,
self
.
theclass
)
)
self
.
assert
IsI
nstance
(
self
.
theclass
.
min
,
self
.
theclass
)
self
.
assert
True
(
isi
nstance
(
self
.
theclass
.
max
,
self
.
theclass
)
)
self
.
assert
IsI
nstance
(
self
.
theclass
.
max
,
self
.
theclass
)
self
.
assert
True
(
isi
nstance
(
self
.
theclass
.
resolution
,
timedelta
)
)
self
.
assert
IsI
nstance
(
self
.
theclass
.
resolution
,
timedelta
)
self
.
assertTrue
(
self
.
theclass
.
max
>
self
.
theclass
.
min
)
self
.
assertTrue
(
self
.
theclass
.
max
>
self
.
theclass
.
min
)
def
test_extreme_timedelta
(
self
):
def
test_extreme_timedelta
(
self
):
...
@@ -1891,9 +1891,9 @@ class TestTime(HarmlessMixedComparison, unittest.TestCase):
...
@@ -1891,9 +1891,9 @@ class TestTime(HarmlessMixedComparison, unittest.TestCase):
"%s(23, 15)"
%
name
)
"%s(23, 15)"
%
name
)
def
test_resolution_info
(
self
):
def
test_resolution_info
(
self
):
self
.
assert
True
(
isi
nstance
(
self
.
theclass
.
min
,
self
.
theclass
)
)
self
.
assert
IsI
nstance
(
self
.
theclass
.
min
,
self
.
theclass
)
self
.
assert
True
(
isi
nstance
(
self
.
theclass
.
max
,
self
.
theclass
)
)
self
.
assert
IsI
nstance
(
self
.
theclass
.
max
,
self
.
theclass
)
self
.
assert
True
(
isi
nstance
(
self
.
theclass
.
resolution
,
timedelta
)
)
self
.
assert
IsI
nstance
(
self
.
theclass
.
resolution
,
timedelta
)
self
.
assertTrue
(
self
.
theclass
.
max
>
self
.
theclass
.
min
)
self
.
assertTrue
(
self
.
theclass
.
max
>
self
.
theclass
.
min
)
def
test_pickling
(
self
):
def
test_pickling
(
self
):
...
@@ -2260,7 +2260,7 @@ class TestTimeTZ(TestTime, TZInfoBase, unittest.TestCase):
...
@@ -2260,7 +2260,7 @@ class TestTimeTZ(TestTime, TZInfoBase, unittest.TestCase):
green
=
pickler
.
dumps
(
orig
,
proto
)
green
=
pickler
.
dumps
(
orig
,
proto
)
derived
=
unpickler
.
loads
(
green
)
derived
=
unpickler
.
loads
(
green
)
self
.
assertEqual
(
orig
,
derived
)
self
.
assertEqual
(
orig
,
derived
)
self
.
assert
True
(
isi
nstance
(
derived
.
tzinfo
,
PicklableFixedOffset
)
)
self
.
assert
IsI
nstance
(
derived
.
tzinfo
,
PicklableFixedOffset
)
self
.
assertEqual
(
derived
.
utcoffset
(),
timedelta
(
minutes
=-
300
))
self
.
assertEqual
(
derived
.
utcoffset
(),
timedelta
(
minutes
=-
300
))
self
.
assertEqual
(
derived
.
tzname
(),
'cookie'
)
self
.
assertEqual
(
derived
.
tzname
(),
'cookie'
)
...
@@ -2487,8 +2487,7 @@ class TestDateTimeTZ(TestDateTime, TZInfoBase, unittest.TestCase):
...
@@ -2487,8 +2487,7 @@ class TestDateTimeTZ(TestDateTime, TZInfoBase, unittest.TestCase):
green
=
pickler
.
dumps
(
orig
,
proto
)
green
=
pickler
.
dumps
(
orig
,
proto
)
derived
=
unpickler
.
loads
(
green
)
derived
=
unpickler
.
loads
(
green
)
self
.
assertEqual
(
orig
,
derived
)
self
.
assertEqual
(
orig
,
derived
)
self
.
assertTrue
(
isinstance
(
derived
.
tzinfo
,
self
.
assertIsInstance
(
derived
.
tzinfo
,
PicklableFixedOffset
)
PicklableFixedOffset
))
self
.
assertEqual
(
derived
.
utcoffset
(),
timedelta
(
minutes
=-
300
))
self
.
assertEqual
(
derived
.
utcoffset
(),
timedelta
(
minutes
=-
300
))
self
.
assertEqual
(
derived
.
tzname
(),
'cookie'
)
self
.
assertEqual
(
derived
.
tzname
(),
'cookie'
)
...
...
This diff is collapsed.
Click to expand it.
Lib/test/test_decimal.py
View file @
b0f5adc3
...
@@ -521,7 +521,7 @@ class DecimalExplicitConstructionTest(unittest.TestCase):
...
@@ -521,7 +521,7 @@ class DecimalExplicitConstructionTest(unittest.TestCase):
# from int
# from int
d
=
nc
.
create_decimal
(
456
)
d
=
nc
.
create_decimal
(
456
)
self
.
assert
True
(
isi
nstance
(
d
,
Decimal
)
)
self
.
assert
IsI
nstance
(
d
,
Decimal
)
self
.
assertEqual
(
nc
.
create_decimal
(
45678
),
self
.
assertEqual
(
nc
.
create_decimal
(
45678
),
nc
.
create_decimal
(
'457E+2'
))
nc
.
create_decimal
(
'457E+2'
))
...
@@ -1529,7 +1529,7 @@ class DecimalPythonAPItests(unittest.TestCase):
...
@@ -1529,7 +1529,7 @@ class DecimalPythonAPItests(unittest.TestCase):
def
test_abc
(
self
):
def
test_abc
(
self
):
self
.
assertTrue
(
issubclass
(
Decimal
,
numbers
.
Number
))
self
.
assertTrue
(
issubclass
(
Decimal
,
numbers
.
Number
))
self
.
assertTrue
(
not
issubclass
(
Decimal
,
numbers
.
Real
))
self
.
assertTrue
(
not
issubclass
(
Decimal
,
numbers
.
Real
))
self
.
assert
True
(
isi
nstance
(
Decimal
(
0
),
numbers
.
Number
)
)
self
.
assert
IsI
nstance
(
Decimal
(
0
),
numbers
.
Number
)
self
.
assertTrue
(
not
isinstance
(
Decimal
(
0
),
numbers
.
Real
))
self
.
assertTrue
(
not
isinstance
(
Decimal
(
0
),
numbers
.
Real
))
def
test_pickle
(
self
):
def
test_pickle
(
self
):
...
...
This diff is collapsed.
Click to expand it.
Lib/test/test_descr.py
View file @
b0f5adc3
...
@@ -410,11 +410,11 @@ class ClassPropertiesAndMethods(unittest.TestCase):
...
@@ -410,11 +410,11 @@ class ClassPropertiesAndMethods(unittest.TestCase):
def
test_python_dicts
(
self
):
def
test_python_dicts
(
self
):
# Testing Python subclass of dict...
# Testing Python subclass of dict...
self
.
assertTrue
(
issubclass
(
dict
,
dict
))
self
.
assertTrue
(
issubclass
(
dict
,
dict
))
self
.
assert
True
(
isi
nstance
({},
dict
)
)
self
.
assert
IsI
nstance
({},
dict
)
d
=
dict
()
d
=
dict
()
self
.
assertEqual
(
d
,
{})
self
.
assertEqual
(
d
,
{})
self
.
assertTrue
(
d
.
__class__
is
dict
)
self
.
assertTrue
(
d
.
__class__
is
dict
)
self
.
assert
True
(
isi
nstance
(
d
,
dict
)
)
self
.
assert
IsI
nstance
(
d
,
dict
)
class
C
(
dict
):
class
C
(
dict
):
state
=
-
1
state
=
-
1
def
__init__
(
self_local
,
*
a
,
**
kw
):
def
__init__
(
self_local
,
*
a
,
**
kw
):
...
@@ -427,7 +427,7 @@ class ClassPropertiesAndMethods(unittest.TestCase):
...
@@ -427,7 +427,7 @@ class ClassPropertiesAndMethods(unittest.TestCase):
def
__getitem__
(
self
,
key
):
def
__getitem__
(
self
,
key
):
return
self
.
get
(
key
,
0
)
return
self
.
get
(
key
,
0
)
def
__setitem__
(
self_local
,
key
,
value
):
def
__setitem__
(
self_local
,
key
,
value
):
self
.
assert
True
(
isi
nstance
(
key
,
type
(
0
))
)
self
.
assert
IsI
nstance
(
key
,
type
(
0
))
dict
.
__setitem__
(
self_local
,
key
,
value
)
dict
.
__setitem__
(
self_local
,
key
,
value
)
def
setstate
(
self
,
state
):
def
setstate
(
self
,
state
):
self
.
state
=
state
self
.
state
=
state
...
@@ -1222,7 +1222,7 @@ order (MRO) for bases """
...
@@ -1222,7 +1222,7 @@ order (MRO) for bases """
MyABC
.
register
(
Unrelated
)
MyABC
.
register
(
Unrelated
)
u
=
Unrelated
()
u
=
Unrelated
()
self
.
assert
True
(
isi
nstance
(
u
,
MyABC
)
)
self
.
assert
IsI
nstance
(
u
,
MyABC
)
# This used to crash
# This used to crash
self
.
assertRaises
(
TypeError
,
MyABC
.
a
.
__set__
,
u
,
3
)
self
.
assertRaises
(
TypeError
,
MyABC
.
a
.
__set__
,
u
,
3
)
...
@@ -2025,7 +2025,7 @@ order (MRO) for bases """
...
@@ -2025,7 +2025,7 @@ order (MRO) for bases """
self
.
assertFalse
(
hasattr
(
a
,
"x"
))
self
.
assertFalse
(
hasattr
(
a
,
"x"
))
raw
=
C
.
__dict__
[
'x'
]
raw
=
C
.
__dict__
[
'x'
]
self
.
assert
True
(
isi
nstance
(
raw
,
property
)
)
self
.
assert
IsI
nstance
(
raw
,
property
)
attrs
=
dir
(
raw
)
attrs
=
dir
(
raw
)
self
.
assertIn
(
"__doc__"
,
attrs
)
self
.
assertIn
(
"__doc__"
,
attrs
)
...
@@ -4237,29 +4237,29 @@ order (MRO) for bases """
...
@@ -4237,29 +4237,29 @@ order (MRO) for bases """
pass
pass
a
=
C
()
a
=
C
()
pa
=
Proxy
(
a
)
pa
=
Proxy
(
a
)
self
.
assert
True
(
isi
nstance
(
a
,
C
)
)
# Baseline
self
.
assert
IsI
nstance
(
a
,
C
)
# Baseline
self
.
assert
True
(
isi
nstance
(
pa
,
C
)
)
# Test
self
.
assert
IsI
nstance
(
pa
,
C
)
# Test
# Test with a classic subclass
# Test with a classic subclass
class
D
(
C
):
class
D
(
C
):
pass
pass
a
=
D
()
a
=
D
()
pa
=
Proxy
(
a
)
pa
=
Proxy
(
a
)
self
.
assert
True
(
isi
nstance
(
a
,
C
)
)
# Baseline
self
.
assert
IsI
nstance
(
a
,
C
)
# Baseline
self
.
assert
True
(
isi
nstance
(
pa
,
C
)
)
# Test
self
.
assert
IsI
nstance
(
pa
,
C
)
# Test
# Test with a new-style class
# Test with a new-style class
class
C
(
object
):
class
C
(
object
):
pass
pass
a
=
C
()
a
=
C
()
pa
=
Proxy
(
a
)
pa
=
Proxy
(
a
)
self
.
assert
True
(
isi
nstance
(
a
,
C
)
)
# Baseline
self
.
assert
IsI
nstance
(
a
,
C
)
# Baseline
self
.
assert
True
(
isi
nstance
(
pa
,
C
)
)
# Test
self
.
assert
IsI
nstance
(
pa
,
C
)
# Test
# Test with a new-style subclass
# Test with a new-style subclass
class
D
(
C
):
class
D
(
C
):
pass
pass
a
=
D
()
a
=
D
()
pa
=
Proxy
(
a
)
pa
=
Proxy
(
a
)
self
.
assert
True
(
isi
nstance
(
a
,
C
)
)
# Baseline
self
.
assert
IsI
nstance
(
a
,
C
)
# Baseline
self
.
assert
True
(
isi
nstance
(
pa
,
C
)
)
# Test
self
.
assert
IsI
nstance
(
pa
,
C
)
# Test
def
test_proxy_super
(
self
):
def
test_proxy_super
(
self
):
# Testing super() for a proxy object...
# Testing super() for a proxy object...
...
...
This diff is collapsed.
Click to expand it.
Lib/test/test_dict.py
View file @
b0f5adc3
...
@@ -225,7 +225,7 @@ class DictTest(unittest.TestCase):
...
@@ -225,7 +225,7 @@ class DictTest(unittest.TestCase):
return
UserDict
.
UserDict
()
return
UserDict
.
UserDict
()
ud
=
mydict
.
fromkeys
(
'ab'
)
ud
=
mydict
.
fromkeys
(
'ab'
)
self
.
assertEqual
(
ud
,
{
'a'
:
None
,
'b'
:
None
})
self
.
assertEqual
(
ud
,
{
'a'
:
None
,
'b'
:
None
})
self
.
assert
True
(
isi
nstance
(
ud
,
UserDict
.
UserDict
)
)
self
.
assert
IsI
nstance
(
ud
,
UserDict
.
UserDict
)
self
.
assertRaises
(
TypeError
,
dict
.
fromkeys
)
self
.
assertRaises
(
TypeError
,
dict
.
fromkeys
)
class
Exc
(
Exception
):
pass
class
Exc
(
Exception
):
pass
...
...
This diff is collapsed.
Click to expand it.
Lib/test/test_dictviews.py
View file @
b0f5adc3
...
@@ -71,17 +71,17 @@ class DictSetTest(unittest.TestCase):
...
@@ -71,17 +71,17 @@ class DictSetTest(unittest.TestCase):
def
test_dict_repr
(
self
):
def
test_dict_repr
(
self
):
d
=
{
1
:
10
,
"a"
:
"ABC"
}
d
=
{
1
:
10
,
"a"
:
"ABC"
}
self
.
assert
True
(
isi
nstance
(
repr
(
d
),
str
)
)
self
.
assert
IsI
nstance
(
repr
(
d
),
str
)
r
=
repr
(
d
.
viewitems
())
r
=
repr
(
d
.
viewitems
())
self
.
assert
True
(
isi
nstance
(
r
,
str
)
)
self
.
assert
IsI
nstance
(
r
,
str
)
self
.
assertTrue
(
r
==
"dict_items([('a', 'ABC'), (1, 10)])"
or
self
.
assertTrue
(
r
==
"dict_items([('a', 'ABC'), (1, 10)])"
or
r
==
"dict_items([(1, 10), ('a', 'ABC')])"
)
r
==
"dict_items([(1, 10), ('a', 'ABC')])"
)
r
=
repr
(
d
.
viewkeys
())
r
=
repr
(
d
.
viewkeys
())
self
.
assert
True
(
isi
nstance
(
r
,
str
)
)
self
.
assert
IsI
nstance
(
r
,
str
)
self
.
assertTrue
(
r
==
"dict_keys(['a', 1])"
or
self
.
assertTrue
(
r
==
"dict_keys(['a', 1])"
or
r
==
"dict_keys([1, 'a'])"
)
r
==
"dict_keys([1, 'a'])"
)
r
=
repr
(
d
.
viewvalues
())
r
=
repr
(
d
.
viewvalues
())
self
.
assert
True
(
isi
nstance
(
r
,
str
)
)
self
.
assert
IsI
nstance
(
r
,
str
)
self
.
assertTrue
(
r
==
"dict_values(['ABC', 10])"
or
self
.
assertTrue
(
r
==
"dict_values(['ABC', 10])"
or
r
==
"dict_values([10, 'ABC'])"
)
r
==
"dict_values([10, 'ABC'])"
)
...
...
This diff is collapsed.
Click to expand it.
Lib/test/test_dummy_thread.py
View file @
b0f5adc3
...
@@ -92,16 +92,16 @@ class MiscTests(unittest.TestCase):
...
@@ -92,16 +92,16 @@ class MiscTests(unittest.TestCase):
def
test_ident
(
self
):
def
test_ident
(
self
):
#Test sanity of _thread.get_ident()
#Test sanity of _thread.get_ident()
self
.
assert
True
(
isi
nstance
(
_thread
.
get_ident
(),
int
)
,
self
.
assert
IsI
nstance
(
_thread
.
get_ident
(),
int
,
"_thread.get_ident() returned a non-integer"
)
"_thread.get_ident() returned a non-integer"
)
self
.
assertTrue
(
_thread
.
get_ident
()
!=
0
,
self
.
assertTrue
(
_thread
.
get_ident
()
!=
0
,
"_thread.get_ident() returned 0"
)
"_thread.get_ident() returned 0"
)
def
test_LockType
(
self
):
def
test_LockType
(
self
):
#Make sure _thread.LockType is the same type as _thread.allocate_locke()
#Make sure _thread.LockType is the same type as _thread.allocate_locke()
self
.
assert
True
(
isi
nstance
(
_thread
.
allocate_lock
(),
_thread
.
LockType
)
,
self
.
assert
IsI
nstance
(
_thread
.
allocate_lock
(),
_thread
.
LockType
,
"_thread.LockType is not an instance of what
is
"
"_thread.LockType is not an instance of what "
"
returned by _thread.allocate_lock()"
)
"is
returned by _thread.allocate_lock()"
)
def
test_interrupt_main
(
self
):
def
test_interrupt_main
(
self
):
#Calling start_new_thread with a function that executes interrupt_main
#Calling start_new_thread with a function that executes interrupt_main
...
...
This diff is collapsed.
Click to expand it.
Lib/test/test_ftplib.py
View file @
b0f5adc3
...
@@ -582,36 +582,36 @@ class TestTLS_FTPClass(TestCase):
...
@@ -582,36 +582,36 @@ class TestTLS_FTPClass(TestCase):
self
.
server
.
stop
()
self
.
server
.
stop
()
def
test_control_connection
(
self
):
def
test_control_connection
(
self
):
self
.
assert
False
(
isi
nstance
(
self
.
client
.
sock
,
ssl
.
SSLSocket
)
)
self
.
assert
NotIsI
nstance
(
self
.
client
.
sock
,
ssl
.
SSLSocket
)
self
.
client
.
auth
()
self
.
client
.
auth
()
self
.
assert
True
(
isi
nstance
(
self
.
client
.
sock
,
ssl
.
SSLSocket
)
)
self
.
assert
IsI
nstance
(
self
.
client
.
sock
,
ssl
.
SSLSocket
)
def
test_data_connection
(
self
):
def
test_data_connection
(
self
):
# clear text
# clear text
sock
=
self
.
client
.
transfercmd
(
'list'
)
sock
=
self
.
client
.
transfercmd
(
'list'
)
self
.
assert
False
(
isi
nstance
(
sock
,
ssl
.
SSLSocket
)
)
self
.
assert
NotIsI
nstance
(
sock
,
ssl
.
SSLSocket
)
sock
.
close
()
sock
.
close
()
self
.
client
.
voidresp
()
self
.
client
.
voidresp
()
# secured, after PROT P
# secured, after PROT P
self
.
client
.
prot_p
()
self
.
client
.
prot_p
()
sock
=
self
.
client
.
transfercmd
(
'list'
)
sock
=
self
.
client
.
transfercmd
(
'list'
)
self
.
assert
True
(
isi
nstance
(
sock
,
ssl
.
SSLSocket
)
)
self
.
assert
IsI
nstance
(
sock
,
ssl
.
SSLSocket
)
sock
.
close
()
sock
.
close
()
self
.
client
.
voidresp
()
self
.
client
.
voidresp
()
# PROT C is issued, the connection must be in cleartext again
# PROT C is issued, the connection must be in cleartext again
self
.
client
.
prot_c
()
self
.
client
.
prot_c
()
sock
=
self
.
client
.
transfercmd
(
'list'
)
sock
=
self
.
client
.
transfercmd
(
'list'
)
self
.
assert
False
(
isi
nstance
(
sock
,
ssl
.
SSLSocket
)
)
self
.
assert
NotIsI
nstance
(
sock
,
ssl
.
SSLSocket
)
sock
.
close
()
sock
.
close
()
self
.
client
.
voidresp
()
self
.
client
.
voidresp
()
def
test_login
(
self
):
def
test_login
(
self
):
# login() is supposed to implicitly secure the control connection
# login() is supposed to implicitly secure the control connection
self
.
assert
False
(
isi
nstance
(
self
.
client
.
sock
,
ssl
.
SSLSocket
)
)
self
.
assert
NotIsI
nstance
(
self
.
client
.
sock
,
ssl
.
SSLSocket
)
self
.
client
.
login
()
self
.
client
.
login
()
self
.
assert
True
(
isi
nstance
(
self
.
client
.
sock
,
ssl
.
SSLSocket
)
)
self
.
assert
IsI
nstance
(
self
.
client
.
sock
,
ssl
.
SSLSocket
)
# make sure that AUTH TLS doesn't get issued again
# make sure that AUTH TLS doesn't get issued again
self
.
client
.
login
()
self
.
client
.
login
()
...
...
This diff is collapsed.
Click to expand it.
Lib/test/test_funcattrs.py
View file @
b0f5adc3
...
@@ -68,7 +68,7 @@ class FunctionPropertiesTest(FuncAttrsTest):
...
@@ -68,7 +68,7 @@ class FunctionPropertiesTest(FuncAttrsTest):
a
=
12
a
=
12
def
f
():
print
a
def
f
():
print
a
c
=
f
.
func_closure
c
=
f
.
func_closure
self
.
assert
True
(
isi
nstance
(
c
,
tuple
)
)
self
.
assert
IsI
nstance
(
c
,
tuple
)
self
.
assertEqual
(
len
(
c
),
1
)
self
.
assertEqual
(
len
(
c
),
1
)
# don't have a type object handy
# don't have a type object handy
self
.
assertEqual
(
c
[
0
].
__class__
.
__name__
,
"cell"
)
self
.
assertEqual
(
c
[
0
].
__class__
.
__name__
,
"cell"
)
...
...
This diff is collapsed.
Click to expand it.
Prev
1
2
3
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment