Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
07627880
Commit
07627880
authored
Mar 21, 2010
by
Florent Xicluna
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#7092 - Silence more py3k deprecation warnings, using test_support.check_py3k_warnings() helper.
parent
8cb253f8
Changes
38
Hide whitespace changes
Inline
Side-by-side
Showing
38 changed files
with
290 additions
and
184 deletions
+290
-184
Lib/test/list_tests.py
Lib/test/list_tests.py
+6
-1
Lib/test/mapping_tests.py
Lib/test/mapping_tests.py
+8
-3
Lib/test/test_StringIO.py
Lib/test/test_StringIO.py
+4
-6
Lib/test/test_array.py
Lib/test/test_array.py
+2
-1
Lib/test/test_ast.py
Lib/test/test_ast.py
+3
-1
Lib/test/test_augassign.py
Lib/test/test_augassign.py
+3
-2
Lib/test/test_bigmem.py
Lib/test/test_bigmem.py
+7
-6
Lib/test/test_bool.py
Lib/test/test_bool.py
+15
-10
Lib/test/test_buffer.py
Lib/test/test_buffer.py
+3
-1
Lib/test/test_builtin.py
Lib/test/test_builtin.py
+14
-9
Lib/test/test_call.py
Lib/test/test_call.py
+6
-3
Lib/test/test_class.py
Lib/test/test_class.py
+7
-3
Lib/test/test_ctypes.py
Lib/test/test_ctypes.py
+7
-5
Lib/test/test_descr.py
Lib/test/test_descr.py
+8
-3
Lib/test/test_doctest.py
Lib/test/test_doctest.py
+10
-9
Lib/test/test_heapq.py
Lib/test/test_heapq.py
+4
-1
Lib/test/test_inspect.py
Lib/test/test_inspect.py
+15
-9
Lib/test/test_iter.py
Lib/test/test_iter.py
+16
-8
Lib/test/test_long.py
Lib/test/test_long.py
+9
-7
Lib/test/test_marshal.py
Lib/test/test_marshal.py
+3
-1
Lib/test/test_multiprocessing.py
Lib/test/test_multiprocessing.py
+3
-1
Lib/test/test_operator.py
Lib/test/test_operator.py
+6
-3
Lib/test/test_peepholer.py
Lib/test/test_peepholer.py
+14
-11
Lib/test/test_richcmp.py
Lib/test/test_richcmp.py
+6
-1
Lib/test/test_set.py
Lib/test/test_set.py
+4
-0
Lib/test/test_sets.py
Lib/test/test_sets.py
+17
-15
Lib/test/test_slice.py
Lib/test/test_slice.py
+2
-1
Lib/test/test_socket.py
Lib/test/test_socket.py
+10
-7
Lib/test/test_sort.py
Lib/test/test_sort.py
+15
-13
Lib/test/test_ssl.py
Lib/test/test_ssl.py
+3
-2
Lib/test/test_syntax.py
Lib/test/test_syntax.py
+3
-1
Lib/test/test_types.py
Lib/test/test_types.py
+6
-2
Lib/test/test_undocumented_details.py
Lib/test/test_undocumented_details.py
+3
-2
Lib/test/test_univnewlines2k.py
Lib/test/test_univnewlines2k.py
+2
-1
Lib/test/test_userdict.py
Lib/test/test_userdict.py
+5
-4
Lib/test/test_userlist.py
Lib/test/test_userlist.py
+3
-1
Lib/test/test_weakref.py
Lib/test/test_weakref.py
+28
-28
Lib/test/test_zipimport_support.py
Lib/test/test_zipimport_support.py
+10
-2
No files found.
Lib/test/list_tests.py
View file @
07627880
...
@@ -36,7 +36,7 @@ class CommonTest(seq_tests.CommonTest):
...
@@ -36,7 +36,7 @@ class CommonTest(seq_tests.CommonTest):
self
.
assertEqual
(
str
(
a0
),
str
(
l0
))
self
.
assertEqual
(
str
(
a0
),
str
(
l0
))
self
.
assertEqual
(
repr
(
a0
),
repr
(
l0
))
self
.
assertEqual
(
repr
(
a0
),
repr
(
l0
))
self
.
assertEqual
(
`a2`
,
`l2`
)
self
.
assertEqual
(
repr
(
a2
),
repr
(
l2
)
)
self
.
assertEqual
(
str
(
a2
),
"[0, 1, 2]"
)
self
.
assertEqual
(
str
(
a2
),
"[0, 1, 2]"
)
self
.
assertEqual
(
repr
(
a2
),
"[0, 1, 2]"
)
self
.
assertEqual
(
repr
(
a2
),
"[0, 1, 2]"
)
...
@@ -421,6 +421,11 @@ class CommonTest(seq_tests.CommonTest):
...
@@ -421,6 +421,11 @@ class CommonTest(seq_tests.CommonTest):
self
.
assertRaises
(
TypeError
,
u
.
reverse
,
42
)
self
.
assertRaises
(
TypeError
,
u
.
reverse
,
42
)
def
test_sort
(
self
):
def
test_sort
(
self
):
with
test_support
.
check_py3k_warnings
(
(
"the cmp argument is not supported"
,
DeprecationWarning
)):
self
.
_test_sort
()
def
_test_sort
(
self
):
u
=
self
.
type2test
([
1
,
0
])
u
=
self
.
type2test
([
1
,
0
])
u
.
sort
()
u
.
sort
()
self
.
assertEqual
(
u
,
[
0
,
1
])
self
.
assertEqual
(
u
,
[
0
,
1
])
...
...
Lib/test/mapping_tests.py
View file @
07627880
# tests common to dict and UserDict
# tests common to dict and UserDict
import
unittest
import
unittest
import
UserDict
import
UserDict
import
test_support
class
BasicTestMappingProtocol
(
unittest
.
TestCase
):
class
BasicTestMappingProtocol
(
unittest
.
TestCase
):
...
@@ -54,13 +55,17 @@ class BasicTestMappingProtocol(unittest.TestCase):
...
@@ -54,13 +55,17 @@ class BasicTestMappingProtocol(unittest.TestCase):
#len
#len
self
.
assertEqual
(
len
(
p
),
0
)
self
.
assertEqual
(
len
(
p
),
0
)
self
.
assertEqual
(
len
(
d
),
len
(
self
.
reference
))
self
.
assertEqual
(
len
(
d
),
len
(
self
.
reference
))
#
has_key
#
in
for
k
in
self
.
reference
:
for
k
in
self
.
reference
:
self
.
assertTrue
(
d
.
has_key
(
k
))
self
.
assertIn
(
k
,
d
)
self
.
assertIn
(
k
,
d
)
for
k
in
self
.
other
:
for
k
in
self
.
other
:
self
.
assertFalse
(
d
.
has_key
(
k
))
self
.
assertNotIn
(
k
,
d
)
self
.
assertNotIn
(
k
,
d
)
#has_key
with
test_support
.
check_py3k_warnings
(
quiet
=
True
):
for
k
in
self
.
reference
:
self
.
assertTrue
(
d
.
has_key
(
k
))
for
k
in
self
.
other
:
self
.
assertFalse
(
d
.
has_key
(
k
))
#cmp
#cmp
self
.
assertEqual
(
cmp
(
p
,
p
),
0
)
self
.
assertEqual
(
cmp
(
p
,
p
),
0
)
self
.
assertEqual
(
cmp
(
d
,
d
),
0
)
self
.
assertEqual
(
cmp
(
d
,
d
),
0
)
...
...
Lib/test/test_StringIO.py
View file @
07627880
...
@@ -137,12 +137,10 @@ class TestBuffercStringIO(TestcStringIO):
...
@@ -137,12 +137,10 @@ class TestBuffercStringIO(TestcStringIO):
def
test_main
():
def
test_main
():
test_support
.
run_unittest
(
test_support
.
run_unittest
(
TestStringIO
,
TestcStringIO
)
TestStringIO
,
with
test_support
.
check_py3k_warnings
((
"buffer.. not supported"
,
TestcStringIO
,
DeprecationWarning
)):
TestBufferStringIO
,
test_support
.
run_unittest
(
TestBufferStringIO
,
TestBuffercStringIO
)
TestBuffercStringIO
)
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
test_main
()
test_main
()
Lib/test/test_array.py
View file @
07627880
...
@@ -749,7 +749,8 @@ class BaseTest(unittest.TestCase):
...
@@ -749,7 +749,8 @@ class BaseTest(unittest.TestCase):
def
test_buffer
(
self
):
def
test_buffer
(
self
):
a
=
array
.
array
(
self
.
typecode
,
self
.
example
)
a
=
array
.
array
(
self
.
typecode
,
self
.
example
)
b
=
buffer
(
a
)
with
test_support
.
check_py3k_warnings
():
b
=
buffer
(
a
)
self
.
assertEqual
(
b
[
0
],
a
.
tostring
()[
0
])
self
.
assertEqual
(
b
[
0
],
a
.
tostring
()[
0
])
def
test_weakref
(
self
):
def
test_weakref
(
self
):
...
...
Lib/test/test_ast.py
View file @
07627880
...
@@ -302,7 +302,9 @@ class ASTHelpers_Test(unittest.TestCase):
...
@@ -302,7 +302,9 @@ class ASTHelpers_Test(unittest.TestCase):
def
test_main
():
def
test_main
():
test_support
.
run_unittest
(
AST_Tests
,
ASTHelpers_Test
)
with
test_support
.
check_py3k_warnings
((
"backquote not supported"
,
SyntaxWarning
)):
test_support
.
run_unittest
(
AST_Tests
,
ASTHelpers_Test
)
def
main
():
def
main
():
if
__name__
!=
'__main__'
:
if
__name__
!=
'__main__'
:
...
...
Lib/test/test_augassign.py
View file @
07627880
# Augmented assignment test.
# Augmented assignment test.
from
test.test_support
import
run_unittest
from
test.test_support
import
run_unittest
,
check_py3k_warnings
import
unittest
import
unittest
...
@@ -324,7 +324,8 @@ __ilshift__ called
...
@@ -324,7 +324,8 @@ __ilshift__ called
'''
.
splitlines
())
'''
.
splitlines
())
def
test_main
():
def
test_main
():
run_unittest
(
AugAssignTest
)
with
check_py3k_warnings
((
"classic int division"
,
DeprecationWarning
)):
run_unittest
(
AugAssignTest
)
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
test_main
()
test_main
()
Lib/test/test_bigmem.py
View file @
07627880
...
@@ -97,21 +97,21 @@ class StrTest(unittest.TestCase):
...
@@ -97,21 +97,21 @@ class StrTest(unittest.TestCase):
def
test_encode
(
self
,
size
):
def
test_encode
(
self
,
size
):
return
self
.
basic_encode_test
(
size
,
'utf-8'
)
return
self
.
basic_encode_test
(
size
,
'utf-8'
)
@
precisionbigmemtest
(
size
=
_4G
/
6
+
2
,
memuse
=
2
)
@
precisionbigmemtest
(
size
=
_4G
/
/
6
+
2
,
memuse
=
2
)
def
test_encode_raw_unicode_escape
(
self
,
size
):
def
test_encode_raw_unicode_escape
(
self
,
size
):
try
:
try
:
return
self
.
basic_encode_test
(
size
,
'raw_unicode_escape'
)
return
self
.
basic_encode_test
(
size
,
'raw_unicode_escape'
)
except
MemoryError
:
except
MemoryError
:
pass
# acceptable on 32-bit
pass
# acceptable on 32-bit
@
precisionbigmemtest
(
size
=
_4G
/
5
+
70
,
memuse
=
3
)
@
precisionbigmemtest
(
size
=
_4G
/
/
5
+
70
,
memuse
=
3
)
def
test_encode_utf7
(
self
,
size
):
def
test_encode_utf7
(
self
,
size
):
try
:
try
:
return
self
.
basic_encode_test
(
size
,
'utf7'
)
return
self
.
basic_encode_test
(
size
,
'utf7'
)
except
MemoryError
:
except
MemoryError
:
pass
# acceptable on 32-bit
pass
# acceptable on 32-bit
@
precisionbigmemtest
(
size
=
_4G
/
4
+
5
,
memuse
=
6
)
@
precisionbigmemtest
(
size
=
_4G
/
/
4
+
5
,
memuse
=
6
)
def
test_encode_utf32
(
self
,
size
):
def
test_encode_utf32
(
self
,
size
):
try
:
try
:
return
self
.
basic_encode_test
(
size
,
'utf32'
,
expectedsize
=
4
*
size
+
4
)
return
self
.
basic_encode_test
(
size
,
'utf32'
,
expectedsize
=
4
*
size
+
4
)
...
@@ -122,7 +122,7 @@ class StrTest(unittest.TestCase):
...
@@ -122,7 +122,7 @@ class StrTest(unittest.TestCase):
def
test_decodeascii
(
self
,
size
):
def
test_decodeascii
(
self
,
size
):
return
self
.
basic_encode_test
(
size
,
'ascii'
,
c
=
'A'
)
return
self
.
basic_encode_test
(
size
,
'ascii'
,
c
=
'A'
)
@
precisionbigmemtest
(
size
=
_4G
/
5
,
memuse
=
6
+
2
)
@
precisionbigmemtest
(
size
=
_4G
/
/
5
,
memuse
=
6
+
2
)
def
test_unicode_repr_oflw
(
self
,
size
):
def
test_unicode_repr_oflw
(
self
,
size
):
try
:
try
:
s
=
u"
\
uAAAA
"
*
size
s
=
u"
\
uAAAA
"
*
size
...
@@ -516,7 +516,7 @@ class StrTest(unittest.TestCase):
...
@@ -516,7 +516,7 @@ class StrTest(unittest.TestCase):
self
.
assertEquals
(
s
.
count
(
'
\
\
'
),
size
)
self
.
assertEquals
(
s
.
count
(
'
\
\
'
),
size
)
self
.
assertEquals
(
s
.
count
(
'0'
),
size
*
2
)
self
.
assertEquals
(
s
.
count
(
'0'
),
size
*
2
)
@
bigmemtest
(
minsize
=
2
**
32
/
5
,
memuse
=
6
+
2
)
@
bigmemtest
(
minsize
=
2
**
32
/
/
5
,
memuse
=
6
+
2
)
def
test_unicode_repr
(
self
,
size
):
def
test_unicode_repr
(
self
,
size
):
s
=
u"
\
uAAAA
"
*
size
s
=
u"
\
uAAAA
"
*
size
self
.
assertTrue
(
len
(
repr
(
s
))
>
size
)
self
.
assertTrue
(
len
(
repr
(
s
))
>
size
)
...
@@ -1053,7 +1053,8 @@ class BufferTest(unittest.TestCase):
...
@@ -1053,7 +1053,8 @@ class BufferTest(unittest.TestCase):
@
precisionbigmemtest
(
size
=
_1G
,
memuse
=
4
)
@
precisionbigmemtest
(
size
=
_1G
,
memuse
=
4
)
def
test_repeat
(
self
,
size
):
def
test_repeat
(
self
,
size
):
try
:
try
:
b
=
buffer
(
"AAAA"
)
*
size
with
test_support
.
check_py3k_warnings
():
b
=
buffer
(
"AAAA"
)
*
size
except
MemoryError
:
except
MemoryError
:
pass
# acceptable on 32-bit
pass
# acceptable on 32-bit
else
:
else
:
...
...
Lib/test/test_bool.py
View file @
07627880
...
@@ -85,10 +85,10 @@ class BoolTest(unittest.TestCase):
...
@@ -85,10 +85,10 @@ class BoolTest(unittest.TestCase):
self
.
assertEqual
(
False
*
1
,
0
)
self
.
assertEqual
(
False
*
1
,
0
)
self
.
assertIsNot
(
False
*
1
,
False
)
self
.
assertIsNot
(
False
*
1
,
False
)
self
.
assertEqual
(
True
/
1
,
1
)
self
.
assertEqual
(
True
/
/
1
,
1
)
self
.
assertIsNot
(
True
/
1
,
True
)
self
.
assertIsNot
(
True
/
/
1
,
True
)
self
.
assertEqual
(
False
/
1
,
0
)
self
.
assertEqual
(
False
/
/
1
,
0
)
self
.
assertIsNot
(
False
/
1
,
False
)
self
.
assertIsNot
(
False
/
/
1
,
False
)
for
b
in
False
,
True
:
for
b
in
False
,
True
:
for
i
in
0
,
1
,
2
:
for
i
in
0
,
1
,
2
:
...
@@ -162,8 +162,9 @@ class BoolTest(unittest.TestCase):
...
@@ -162,8 +162,9 @@ class BoolTest(unittest.TestCase):
self
.
assertIs
(
hasattr
([],
"wobble"
),
False
)
self
.
assertIs
(
hasattr
([],
"wobble"
),
False
)
def
test_callable
(
self
):
def
test_callable
(
self
):
self
.
assertIs
(
callable
(
len
),
True
)
with
test_support
.
check_py3k_warnings
():
self
.
assertIs
(
callable
(
1
),
False
)
self
.
assertIs
(
callable
(
len
),
True
)
self
.
assertIs
(
callable
(
1
),
False
)
def
test_isinstance
(
self
):
def
test_isinstance
(
self
):
self
.
assertIs
(
isinstance
(
True
,
bool
),
True
)
self
.
assertIs
(
isinstance
(
True
,
bool
),
True
)
...
@@ -178,8 +179,11 @@ class BoolTest(unittest.TestCase):
...
@@ -178,8 +179,11 @@ class BoolTest(unittest.TestCase):
self
.
assertIs
(
issubclass
(
int
,
bool
),
False
)
self
.
assertIs
(
issubclass
(
int
,
bool
),
False
)
def
test_haskey
(
self
):
def
test_haskey
(
self
):
self
.
assertIs
({}.
has_key
(
1
),
False
)
self
.
assertIs
(
1
in
{},
False
)
self
.
assertIs
({
1
:
1
}.
has_key
(
1
),
True
)
self
.
assertIs
(
1
in
{
1
:
1
},
True
)
with
test_support
.
check_py3k_warnings
():
self
.
assertIs
({}.
has_key
(
1
),
False
)
self
.
assertIs
({
1
:
1
}.
has_key
(
1
),
True
)
def
test_string
(
self
):
def
test_string
(
self
):
self
.
assertIs
(
"xyz"
.
endswith
(
"z"
),
True
)
self
.
assertIs
(
"xyz"
.
endswith
(
"z"
),
True
)
...
@@ -251,8 +255,9 @@ class BoolTest(unittest.TestCase):
...
@@ -251,8 +255,9 @@ class BoolTest(unittest.TestCase):
import
operator
import
operator
self
.
assertIs
(
operator
.
truth
(
0
),
False
)
self
.
assertIs
(
operator
.
truth
(
0
),
False
)
self
.
assertIs
(
operator
.
truth
(
1
),
True
)
self
.
assertIs
(
operator
.
truth
(
1
),
True
)
self
.
assertIs
(
operator
.
isCallable
(
0
),
False
)
with
test_support
.
check_py3k_warnings
():
self
.
assertIs
(
operator
.
isCallable
(
len
),
True
)
self
.
assertIs
(
operator
.
isCallable
(
0
),
False
)
self
.
assertIs
(
operator
.
isCallable
(
len
),
True
)
self
.
assertIs
(
operator
.
isNumberType
(
None
),
False
)
self
.
assertIs
(
operator
.
isNumberType
(
None
),
False
)
self
.
assertIs
(
operator
.
isNumberType
(
0
),
True
)
self
.
assertIs
(
operator
.
isNumberType
(
0
),
True
)
self
.
assertIs
(
operator
.
not_
(
1
),
False
)
self
.
assertIs
(
operator
.
not_
(
1
),
False
)
...
...
Lib/test/test_buffer.py
View file @
07627880
...
@@ -23,7 +23,9 @@ class BufferTests(unittest.TestCase):
...
@@ -23,7 +23,9 @@ class BufferTests(unittest.TestCase):
def
test_main
():
def
test_main
():
test_support
.
run_unittest
(
BufferTests
)
with
test_support
.
check_py3k_warnings
((
"buffer.. not supported"
,
DeprecationWarning
)):
test_support
.
run_unittest
(
BufferTests
)
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
test_main
()
test_main
()
Lib/test/test_builtin.py
View file @
07627880
...
@@ -3,14 +3,10 @@
...
@@ -3,14 +3,10 @@
import
platform
import
platform
import
unittest
import
unittest
from
test.test_support
import
fcmp
,
have_unicode
,
TESTFN
,
unlink
,
\
from
test.test_support
import
fcmp
,
have_unicode
,
TESTFN
,
unlink
,
\
run_unittest
run_unittest
,
check_py3k_warnings
from
operator
import
neg
from
operator
import
neg
import
sys
,
warnings
,
cStringIO
,
random
,
UserDict
import
sys
,
cStringIO
,
random
,
UserDict
warnings
.
filterwarnings
(
"ignore"
,
"hex../oct.. of negative int"
,
FutureWarning
,
__name__
)
warnings
.
filterwarnings
(
"ignore"
,
"integer argument expected"
,
DeprecationWarning
,
"unittest"
)
# count the number of test runs.
# count the number of test runs.
# used to skip running test_execfile() multiple times
# used to skip running test_execfile() multiple times
...
@@ -419,7 +415,9 @@ class BuiltinTest(unittest.TestCase):
...
@@ -419,7 +415,9 @@ class BuiltinTest(unittest.TestCase):
f
.
write
(
'z = z+1
\
n
'
)
f
.
write
(
'z = z+1
\
n
'
)
f
.
write
(
'z = z*2
\
n
'
)
f
.
write
(
'z = z*2
\
n
'
)
f
.
close
()
f
.
close
()
execfile
(
TESTFN
)
with
check_py3k_warnings
((
"execfile.. not supported in 3.x"
,
DeprecationWarning
)):
execfile
(
TESTFN
)
def
test_execfile
(
self
):
def
test_execfile
(
self
):
global
numruns
global
numruns
...
@@ -1542,17 +1540,24 @@ class TestSorted(unittest.TestCase):
...
@@ -1542,17 +1540,24 @@ class TestSorted(unittest.TestCase):
data
=
'The quick Brown fox Jumped over The lazy Dog'
.
split
()
data
=
'The quick Brown fox Jumped over The lazy Dog'
.
split
()
self
.
assertRaises
(
TypeError
,
sorted
,
data
,
None
,
lambda
x
,
y
:
0
)
self
.
assertRaises
(
TypeError
,
sorted
,
data
,
None
,
lambda
x
,
y
:
0
)
def
_run_unittest
(
*
args
):
with
check_py3k_warnings
(
(
".+ not supported in 3.x"
,
DeprecationWarning
),
(
".+ is renamed to imp.reload"
,
DeprecationWarning
),
(
"classic int division"
,
DeprecationWarning
)):
run_unittest
(
*
args
)
def
test_main
(
verbose
=
None
):
def
test_main
(
verbose
=
None
):
test_classes
=
(
BuiltinTest
,
TestSorted
)
test_classes
=
(
BuiltinTest
,
TestSorted
)
run_unittest
(
*
test_classes
)
_
run_unittest
(
*
test_classes
)
# verify reference counting
# verify reference counting
if
verbose
and
hasattr
(
sys
,
"gettotalrefcount"
):
if
verbose
and
hasattr
(
sys
,
"gettotalrefcount"
):
import
gc
import
gc
counts
=
[
None
]
*
5
counts
=
[
None
]
*
5
for
i
in
xrange
(
len
(
counts
)):
for
i
in
xrange
(
len
(
counts
)):
run_unittest
(
*
test_classes
)
_
run_unittest
(
*
test_classes
)
gc
.
collect
()
gc
.
collect
()
counts
[
i
]
=
sys
.
gettotalrefcount
()
counts
[
i
]
=
sys
.
gettotalrefcount
()
print
counts
print
counts
...
...
Lib/test/test_call.py
View file @
07627880
...
@@ -12,7 +12,8 @@ class CFunctionCalls(unittest.TestCase):
...
@@ -12,7 +12,8 @@ class CFunctionCalls(unittest.TestCase):
self
.
assertRaises
(
TypeError
,
{}.
has_key
)
self
.
assertRaises
(
TypeError
,
{}.
has_key
)
def
test_varargs1
(
self
):
def
test_varargs1
(
self
):
{}.
has_key
(
0
)
with
test_support
.
check_py3k_warnings
():
{}.
has_key
(
0
)
def
test_varargs2
(
self
):
def
test_varargs2
(
self
):
self
.
assertRaises
(
TypeError
,
{}.
has_key
,
0
,
1
)
self
.
assertRaises
(
TypeError
,
{}.
has_key
,
0
,
1
)
...
@@ -24,11 +25,13 @@ class CFunctionCalls(unittest.TestCase):
...
@@ -24,11 +25,13 @@ class CFunctionCalls(unittest.TestCase):
pass
pass
def
test_varargs1_ext
(
self
):
def
test_varargs1_ext
(
self
):
{}.
has_key
(
*
(
0
,))
with
test_support
.
check_py3k_warnings
():
{}.
has_key
(
*
(
0
,))
def
test_varargs2_ext
(
self
):
def
test_varargs2_ext
(
self
):
try
:
try
:
{}.
has_key
(
*
(
1
,
2
))
with
test_support
.
check_py3k_warnings
():
{}.
has_key
(
*
(
1
,
2
))
except
TypeError
:
except
TypeError
:
pass
pass
else
:
else
:
...
...
Lib/test/test_class.py
View file @
07627880
...
@@ -407,7 +407,7 @@ class ClassTests(unittest.TestCase):
...
@@ -407,7 +407,7 @@ class ClassTests(unittest.TestCase):
self
.
assertCallStack
([(
"__coerce__"
,
(
testme
,
1
)),
(
'__cmp__'
,
(
testme
,
1
))])
self
.
assertCallStack
([(
"__coerce__"
,
(
testme
,
1
)),
(
'__cmp__'
,
(
testme
,
1
))])
callLst
[:]
=
[]
callLst
[:]
=
[]
testme
<>
1
# XXX kill this in py3k
eval
(
'testme <> 1'
)
# XXX kill this in py3k
self
.
assertCallStack
([(
"__coerce__"
,
(
testme
,
1
)),
(
'__cmp__'
,
(
testme
,
1
))])
self
.
assertCallStack
([(
"__coerce__"
,
(
testme
,
1
)),
(
'__cmp__'
,
(
testme
,
1
))])
callLst
[:]
=
[]
callLst
[:]
=
[]
...
@@ -427,7 +427,7 @@ class ClassTests(unittest.TestCase):
...
@@ -427,7 +427,7 @@ class ClassTests(unittest.TestCase):
self
.
assertCallStack
([(
"__coerce__"
,
(
testme
,
1
)),
(
'__cmp__'
,
(
1
,
testme
))])
self
.
assertCallStack
([(
"__coerce__"
,
(
testme
,
1
)),
(
'__cmp__'
,
(
1
,
testme
))])
callLst
[:]
=
[]
callLst
[:]
=
[]
1
<>
testme
eval
(
'1 <> testme'
)
self
.
assertCallStack
([(
"__coerce__"
,
(
testme
,
1
)),
(
'__cmp__'
,
(
1
,
testme
))])
self
.
assertCallStack
([(
"__coerce__"
,
(
testme
,
1
)),
(
'__cmp__'
,
(
1
,
testme
))])
callLst
[:]
=
[]
callLst
[:]
=
[]
...
@@ -616,7 +616,11 @@ class ClassTests(unittest.TestCase):
...
@@ -616,7 +616,11 @@ class ClassTests(unittest.TestCase):
hash
(
a
.
f
)
hash
(
a
.
f
)
def
test_main
():
def
test_main
():
test_support
.
run_unittest
(
ClassTests
)
with
test_support
.
check_py3k_warnings
(
(
".+__(get|set|del)slice__ has been removed"
,
DeprecationWarning
),
(
"classic int division"
,
DeprecationWarning
),
(
"<> not supported"
,
DeprecationWarning
)):
test_support
.
run_unittest
(
ClassTests
)
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
test_main
()
test_main
()
Lib/test/test_ctypes.py
View file @
07627880
import
unittest
import
unittest
from
test.test_support
import
run_unittest
,
import_module
from
test.test_support
import
run_unittest
,
import_module
,
check_py3k_warnings
#Skip tests if _ctypes module does not exist
#Skip tests if _ctypes module does not exist
import_module
(
'_ctypes'
)
import_module
(
'_ctypes'
)
import
ctypes.test
def
test_main
():
def
test_main
():
skipped
,
testcases
=
ctypes
.
test
.
get_tests
(
ctypes
.
test
,
"test_*.py"
,
verbosity
=
0
)
with
check_py3k_warnings
((
"buffer.. not supported"
,
DeprecationWarning
),
suites
=
[
unittest
.
makeSuite
(
t
)
for
t
in
testcases
]
(
"classic (int|long) division"
,
DeprecationWarning
)):
run_unittest
(
unittest
.
TestSuite
(
suites
))
import
ctypes.test
skipped
,
testcases
=
ctypes
.
test
.
get_tests
(
ctypes
.
test
,
"test_*.py"
,
verbosity
=
0
)
suites
=
[
unittest
.
makeSuite
(
t
)
for
t
in
testcases
]
run_unittest
(
unittest
.
TestSuite
(
suites
))
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
test_main
()
test_main
()
Lib/test/test_descr.py
View file @
07627880
...
@@ -4622,9 +4622,14 @@ class PTypesLongInitTest(unittest.TestCase):
...
@@ -4622,9 +4622,14 @@ class PTypesLongInitTest(unittest.TestCase):
def
test_main
():
def
test_main
():
# Run all local test cases, with PTypesLongInitTest first.
with
test_support
.
check_py3k_warnings
(
test_support
.
run_unittest
(
PTypesLongInitTest
,
OperatorsTest
,
(
"classic (int|long) division"
,
DeprecationWarning
),
ClassPropertiesAndMethods
,
DictProxyTests
)
(
"coerce.. not supported"
,
DeprecationWarning
),
(
"Overriding __cmp__ "
,
DeprecationWarning
),
(
".+__(get|set|del)slice__ has been removed"
,
DeprecationWarning
)):
# Run all local test cases, with PTypesLongInitTest first.
test_support
.
run_unittest
(
PTypesLongInitTest
,
OperatorsTest
,
ClassPropertiesAndMethods
,
DictProxyTests
)
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
test_main
()
test_main
()
Lib/test/test_doctest.py
View file @
07627880
...
@@ -2169,7 +2169,7 @@ We don't want `-v` in sys.argv for these tests.
...
@@ -2169,7 +2169,7 @@ We don't want `-v` in sys.argv for these tests.
>>> doctest.master = None # Reset master.
>>> doctest.master = None # Reset master.
(Note: we'll be clearing doctest.master after each call to
(Note: we'll be clearing doctest.master after each call to
`doctest.testfile`, to supress warnings about multiple tests with the
`doctest.testfile`, to sup
p
ress warnings about multiple tests with the
same name.)
same name.)
Globals may be specified with the `globs` and `extraglobs` parameters:
Globals may be specified with the `globs` and `extraglobs` parameters:
...
@@ -2333,12 +2333,6 @@ bothering with the current sys.stdout encoding.
...
@@ -2333,12 +2333,6 @@ bothering with the current sys.stdout encoding.
# that these use the deprecated doctest.Tester, so should go away (or
# that these use the deprecated doctest.Tester, so should go away (or
# be rewritten) someday.
# be rewritten) someday.
# Ignore all warnings about the use of class Tester in this module.
# Note that the name of this module may differ depending on how it's
# imported, so the use of __name__ is important.
warnings
.
filterwarnings
(
"ignore"
,
"class Tester"
,
DeprecationWarning
,
__name__
,
0
)
def
old_test1
():
r"""
def
old_test1
():
r"""
>>> from doctest import Tester
>>> from doctest import Tester
>>> t = Tester(globs={'x': 42}, verbose=0)
>>> t = Tester(globs={'x': 42}, verbose=0)
...
@@ -2462,9 +2456,16 @@ def old_test4(): """
...
@@ -2462,9 +2456,16 @@ def old_test4(): """
def
test_main
():
def
test_main
():
# Check the doctest cases in doctest itself:
# Check the doctest cases in doctest itself:
test_support
.
run_doctest
(
doctest
,
verbosity
=
True
)
test_support
.
run_doctest
(
doctest
,
verbosity
=
True
)
# Check the doctest cases defined here:
from
test
import
test_doctest
from
test
import
test_doctest
test_support
.
run_doctest
(
test_doctest
,
verbosity
=
True
)
with
test_support
.
check_py3k_warnings
(
(
"backquote not supported"
,
SyntaxWarning
),
(
"execfile.. not supported"
,
DeprecationWarning
)):
# Ignore all warnings about the use of class Tester in this module.
warnings
.
filterwarnings
(
"ignore"
,
"class Tester is deprecated"
,
DeprecationWarning
)
# Check the doctest cases defined here:
test_support
.
run_doctest
(
test_doctest
,
verbosity
=
True
)
import
trace
,
sys
import
trace
,
sys
def
test_coverage
(
coverdir
):
def
test_coverage
(
coverdir
):
...
...
Lib/test/test_heapq.py
View file @
07627880
...
@@ -356,7 +356,10 @@ class TestErrorHandling(unittest.TestCase):
...
@@ -356,7 +356,10 @@ class TestErrorHandling(unittest.TestCase):
for
f
in
(
self
.
module
.
nlargest
,
self
.
module
.
nsmallest
):
for
f
in
(
self
.
module
.
nlargest
,
self
.
module
.
nsmallest
):
for
s
in
(
"123"
,
""
,
range
(
1000
),
(
'do'
,
1.2
),
xrange
(
2000
,
2200
,
5
)):
for
s
in
(
"123"
,
""
,
range
(
1000
),
(
'do'
,
1.2
),
xrange
(
2000
,
2200
,
5
)):
for
g
in
(
G
,
I
,
Ig
,
L
,
R
):
for
g
in
(
G
,
I
,
Ig
,
L
,
R
):
self
.
assertEqual
(
f
(
2
,
g
(
s
)),
f
(
2
,
s
))
with
test_support
.
check_py3k_warnings
(
(
"comparing unequal types not supported"
,
DeprecationWarning
),
quiet
=
True
):
self
.
assertEqual
(
f
(
2
,
g
(
s
)),
f
(
2
,
s
))
self
.
assertEqual
(
f
(
2
,
S
(
s
)),
[])
self
.
assertEqual
(
f
(
2
,
S
(
s
)),
[])
self
.
assertRaises
(
TypeError
,
f
,
2
,
X
(
s
))
self
.
assertRaises
(
TypeError
,
f
,
2
,
X
(
s
))
self
.
assertRaises
(
TypeError
,
f
,
2
,
N
(
s
))
self
.
assertRaises
(
TypeError
,
f
,
2
,
N
(
s
))
...
...
Lib/test/test_inspect.py
View file @
07627880
...
@@ -4,10 +4,13 @@ import unittest
...
@@ -4,10 +4,13 @@ import unittest
import
inspect
import
inspect
import
datetime
import
datetime
from
test.test_support
import
run_unittest
from
test.test_support
import
run_unittest
,
check_py3k_warnings
from
test
import
inspect_fodder
as
mod
with
check_py3k_warnings
(
from
test
import
inspect_fodder2
as
mod2
(
"tuple parameter unpacking has been removed"
,
SyntaxWarning
),
quiet
=
True
):
from
test
import
inspect_fodder
as
mod
from
test
import
inspect_fodder2
as
mod2
# C module for test_findsource_binary
# C module for test_findsource_binary
import
unicodedata
import
unicodedata
...
@@ -29,7 +32,7 @@ if modfile.endswith(('c', 'o')):
...
@@ -29,7 +32,7 @@ if modfile.endswith(('c', 'o')):
import
__builtin__
import
__builtin__
try
:
try
:
1
/
0
1
//
0
except
:
except
:
tb
=
sys
.
exc_traceback
tb
=
sys
.
exc_traceback
...
@@ -420,11 +423,14 @@ class TestClassesAndFunctions(unittest.TestCase):
...
@@ -420,11 +423,14 @@ class TestClassesAndFunctions(unittest.TestCase):
self
.
assertArgSpecEquals
(
A
.
m
,
[
'self'
])
self
.
assertArgSpecEquals
(
A
.
m
,
[
'self'
])
def
test_getargspec_sublistofone
(
self
):
def
test_getargspec_sublistofone
(
self
):
def
sublistOfOne
((
foo
,)):
return
1
with
check_py3k_warnings
(
self
.
assertArgSpecEquals
(
sublistOfOne
,
[[
'foo'
]])
(
"tuple parameter unpacking has been removed"
,
SyntaxWarning
),
(
"parenthesized argument names are invalid"
,
SyntaxWarning
)):
def
fakeSublistOfOne
((
foo
)):
return
1
exec
'def sublistOfOne((foo,)): return 1'
self
.
assertArgSpecEquals
(
fakeSublistOfOne
,
[
'foo'
])
self
.
assertArgSpecEquals
(
sublistOfOne
,
[[
'foo'
]])
exec
'def fakeSublistOfOne((foo)): return 1'
self
.
assertArgSpecEquals
(
fakeSublistOfOne
,
[
'foo'
])
def
test_classify_oldstyle
(
self
):
def
test_classify_oldstyle
(
self
):
class
A
:
class
A
:
...
...
Lib/test/test_iter.py
View file @
07627880
# Test iterators.
# Test iterators.
import
unittest
import
unittest
from
test.test_support
import
run_unittest
,
TESTFN
,
unlink
,
have_unicode
from
test.test_support
import
run_unittest
,
TESTFN
,
unlink
,
have_unicode
,
\
check_py3k_warnings
# Test result of triple loop (too big to inline)
# Test result of triple loop (too big to inline)
TRIPLETS
=
[(
0
,
0
,
0
),
(
0
,
0
,
1
),
(
0
,
0
,
2
),
TRIPLETS
=
[(
0
,
0
,
0
),
(
0
,
0
,
1
),
(
0
,
0
,
2
),
...
@@ -396,21 +397,24 @@ class TestCase(unittest.TestCase):
...
@@ -396,21 +397,24 @@ class TestCase(unittest.TestCase):
# Test map()'s use of iterators.
# Test map()'s use of iterators.
def
test_builtin_map
(
self
):
def
test_builtin_map
(
self
):
self
.
assertEqual
(
map
(
None
,
SequenceClass
(
5
)),
range
(
5
))
self
.
assertEqual
(
map
(
lambda
x
:
x
+
1
,
SequenceClass
(
5
)),
range
(
1
,
6
))
self
.
assertEqual
(
map
(
lambda
x
:
x
+
1
,
SequenceClass
(
5
)),
range
(
1
,
6
))
d
=
{
"one"
:
1
,
"two"
:
2
,
"three"
:
3
}
d
=
{
"one"
:
1
,
"two"
:
2
,
"three"
:
3
}
self
.
assertEqual
(
map
(
None
,
d
),
d
.
keys
())
self
.
assertEqual
(
map
(
lambda
k
,
d
=
d
:
(
k
,
d
[
k
]),
d
),
d
.
items
())
self
.
assertEqual
(
map
(
lambda
k
,
d
=
d
:
(
k
,
d
[
k
]),
d
),
d
.
items
())
dkeys
=
d
.
keys
()
dkeys
=
d
.
keys
()
expected
=
[(
i
<
len
(
d
)
and
dkeys
[
i
]
or
None
,
expected
=
[(
i
<
len
(
d
)
and
dkeys
[
i
]
or
None
,
i
,
i
,
i
<
len
(
d
)
and
dkeys
[
i
]
or
None
)
i
<
len
(
d
)
and
dkeys
[
i
]
or
None
)
for
i
in
range
(
5
)]
for
i
in
range
(
5
)]
self
.
assertEqual
(
map
(
None
,
d
,
SequenceClass
(
5
),
# Deprecated map(None, ...)
iter
(
d
.
iterkeys
())),
with
check_py3k_warnings
():
expected
)
self
.
assertEqual
(
map
(
None
,
SequenceClass
(
5
)),
range
(
5
))
self
.
assertEqual
(
map
(
None
,
d
),
d
.
keys
())
self
.
assertEqual
(
map
(
None
,
d
,
SequenceClass
(
5
),
iter
(
d
.
iterkeys
())),
expected
)
f
=
open
(
TESTFN
,
"w"
)
f
=
open
(
TESTFN
,
"w"
)
try
:
try
:
...
@@ -506,7 +510,11 @@ class TestCase(unittest.TestCase):
...
@@ -506,7 +510,11 @@ class TestCase(unittest.TestCase):
self
.
assertEqual
(
zip
(
x
,
y
),
expected
)
self
.
assertEqual
(
zip
(
x
,
y
),
expected
)
# Test reduces()'s use of iterators.
# Test reduces()'s use of iterators.
def
test_builtin_reduce
(
self
):
def
test_deprecated_builtin_reduce
(
self
):
with
check_py3k_warnings
():
self
.
_test_builtin_reduce
()
def
_test_builtin_reduce
(
self
):
from
operator
import
add
from
operator
import
add
self
.
assertEqual
(
reduce
(
add
,
SequenceClass
(
5
)),
10
)
self
.
assertEqual
(
reduce
(
add
,
SequenceClass
(
5
)),
10
)
self
.
assertEqual
(
reduce
(
add
,
SequenceClass
(
5
),
42
),
52
)
self
.
assertEqual
(
reduce
(
add
,
SequenceClass
(
5
),
42
),
52
)
...
...
Lib/test/test_long.py
View file @
07627880
...
@@ -574,11 +574,12 @@ class LongTest(unittest.TestCase):
...
@@ -574,11 +574,12 @@ class LongTest(unittest.TestCase):
def
__getslice__
(
self
,
i
,
j
):
def
__getslice__
(
self
,
i
,
j
):
return
i
,
j
return
i
,
j
self
.
assertEqual
(
X
()[
-
5L
:
7L
],
(
-
5
,
7
))
with
test_support
.
check_py3k_warnings
():
# use the clamping effect to test the smallest and largest longs
self
.
assertEqual
(
X
()[
-
5L
:
7L
],
(
-
5
,
7
))
# that fit a Py_ssize_t
# use the clamping effect to test the smallest and largest longs
slicemin
,
slicemax
=
X
()[
-
2L
**
100
:
2L
**
100
]
# that fit a Py_ssize_t
self
.
assertEqual
(
X
()[
slicemin
:
slicemax
],
(
slicemin
,
slicemax
))
slicemin
,
slicemax
=
X
()[
-
2L
**
100
:
2L
**
100
]
self
.
assertEqual
(
X
()[
slicemin
:
slicemax
],
(
slicemin
,
slicemax
))
# ----------------------------------- tests of auto int->long conversion
# ----------------------------------- tests of auto int->long conversion
...
@@ -616,8 +617,9 @@ class LongTest(unittest.TestCase):
...
@@ -616,8 +617,9 @@ class LongTest(unittest.TestCase):
checkit
(
x
,
'*'
,
y
)
checkit
(
x
,
'*'
,
y
)
if
y
:
if
y
:
expected
=
longx
/
longy
with
test_support
.
check_py3k_warnings
():
got
=
x
/
y
expected
=
longx
/
longy
got
=
x
/
y
checkit
(
x
,
'/'
,
y
)
checkit
(
x
,
'/'
,
y
)
expected
=
longx
//
longy
expected
=
longx
//
longy
...
...
Lib/test/test_marshal.py
View file @
07627880
...
@@ -129,7 +129,9 @@ class StringTestCase(unittest.TestCase):
...
@@ -129,7 +129,9 @@ class StringTestCase(unittest.TestCase):
def
test_buffer
(
self
):
def
test_buffer
(
self
):
for
s
in
[
""
,
"Andr Previn"
,
"abc"
,
" "
*
10000
]:
for
s
in
[
""
,
"Andr Previn"
,
"abc"
,
" "
*
10000
]:
b
=
buffer
(
s
)
with
test_support
.
check_py3k_warnings
((
"buffer.. not supported"
,
DeprecationWarning
)):
b
=
buffer
(
s
)
new
=
marshal
.
loads
(
marshal
.
dumps
(
b
))
new
=
marshal
.
loads
(
marshal
.
dumps
(
b
))
self
.
assertEqual
(
s
,
new
)
self
.
assertEqual
(
s
,
new
)
marshal
.
dump
(
b
,
file
(
test_support
.
TESTFN
,
"wb"
))
marshal
.
dump
(
b
,
file
(
test_support
.
TESTFN
,
"wb"
))
...
...
Lib/test/test_multiprocessing.py
View file @
07627880
...
@@ -2023,7 +2023,9 @@ def test_main(run=None):
...
@@ -2023,7 +2023,9 @@ def test_main(run=None):
loadTestsFromTestCase
=
unittest
.
defaultTestLoader
.
loadTestsFromTestCase
loadTestsFromTestCase
=
unittest
.
defaultTestLoader
.
loadTestsFromTestCase
suite
=
unittest
.
TestSuite
(
loadTestsFromTestCase
(
tc
)
for
tc
in
testcases
)
suite
=
unittest
.
TestSuite
(
loadTestsFromTestCase
(
tc
)
for
tc
in
testcases
)
run
(
suite
)
with
test_support
.
check_py3k_warnings
(
(
".+__(get|set)slice__ has been removed"
,
DeprecationWarning
)):
run
(
suite
)
ThreadsMixin
.
pool
.
terminate
()
ThreadsMixin
.
pool
.
terminate
()
ProcessesMixin
.
pool
.
terminate
()
ProcessesMixin
.
pool
.
terminate
()
...
...
Lib/test/test_operator.py
View file @
07627880
...
@@ -192,7 +192,9 @@ class OperatorTestCase(unittest.TestCase):
...
@@ -192,7 +192,9 @@ class OperatorTestCase(unittest.TestCase):
class
C
:
class
C
:
pass
pass
def
check
(
self
,
o
,
v
):
def
check
(
self
,
o
,
v
):
self
.
assertTrue
(
operator
.
isCallable
(
o
)
==
callable
(
o
)
==
v
)
with
test_support
.
check_py3k_warnings
():
self
.
assertEqual
(
operator
.
isCallable
(
o
),
v
)
self
.
assertEqual
(
callable
(
o
),
v
)
check
(
self
,
4
,
0
)
check
(
self
,
4
,
0
)
check
(
self
,
operator
.
isCallable
,
1
)
check
(
self
,
operator
.
isCallable
,
1
)
check
(
self
,
C
,
1
)
check
(
self
,
C
,
1
)
...
@@ -306,8 +308,9 @@ class OperatorTestCase(unittest.TestCase):
...
@@ -306,8 +308,9 @@ class OperatorTestCase(unittest.TestCase):
self
.
assertRaises
(
TypeError
,
operator
.
contains
,
None
,
None
)
self
.
assertRaises
(
TypeError
,
operator
.
contains
,
None
,
None
)
self
.
assertTrue
(
operator
.
contains
(
range
(
4
),
2
))
self
.
assertTrue
(
operator
.
contains
(
range
(
4
),
2
))
self
.
assertFalse
(
operator
.
contains
(
range
(
4
),
5
))
self
.
assertFalse
(
operator
.
contains
(
range
(
4
),
5
))
self
.
assertTrue
(
operator
.
sequenceIncludes
(
range
(
4
),
2
))
with
test_support
.
check_py3k_warnings
():
self
.
assertFalse
(
operator
.
sequenceIncludes
(
range
(
4
),
5
))
self
.
assertTrue
(
operator
.
sequenceIncludes
(
range
(
4
),
2
))
self
.
assertFalse
(
operator
.
sequenceIncludes
(
range
(
4
),
5
))
def
test_setitem
(
self
):
def
test_setitem
(
self
):
a
=
range
(
3
)
a
=
range
(
3
)
...
...
Lib/test/test_peepholer.py
View file @
07627880
...
@@ -206,17 +206,20 @@ def test_main(verbose=None):
...
@@ -206,17 +206,20 @@ def test_main(verbose=None):
import
sys
import
sys
from
test
import
test_support
from
test
import
test_support
test_classes
=
(
TestTranforms
,)
test_classes
=
(
TestTranforms
,)
test_support
.
run_unittest
(
*
test_classes
)
with
test_support
.
check_py3k_warnings
(
# verify reference counting
(
"backquote not supported"
,
SyntaxWarning
)):
if
verbose
and
hasattr
(
sys
,
"gettotalrefcount"
):
test_support
.
run_unittest
(
*
test_classes
)
import
gc
counts
=
[
None
]
*
5
# verify reference counting
for
i
in
xrange
(
len
(
counts
)):
if
verbose
and
hasattr
(
sys
,
"gettotalrefcount"
):
test_support
.
run_unittest
(
*
test_classes
)
import
gc
gc
.
collect
()
counts
=
[
None
]
*
5
counts
[
i
]
=
sys
.
gettotalrefcount
()
for
i
in
xrange
(
len
(
counts
)):
print
counts
test_support
.
run_unittest
(
*
test_classes
)
gc
.
collect
()
counts
[
i
]
=
sys
.
gettotalrefcount
()
print
counts
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
test_main
(
verbose
=
True
)
test_main
(
verbose
=
True
)
Lib/test/test_richcmp.py
View file @
07627880
...
@@ -327,7 +327,12 @@ class ListTest(unittest.TestCase):
...
@@ -327,7 +327,12 @@ class ListTest(unittest.TestCase):
self
.
assertIs
(
op
(
x
,
y
),
True
)
self
.
assertIs
(
op
(
x
,
y
),
True
)
def
test_main
():
def
test_main
():
test_support
.
run_unittest
(
VectorTest
,
NumberTest
,
MiscTest
,
DictTest
,
ListTest
)
test_support
.
run_unittest
(
VectorTest
,
NumberTest
,
MiscTest
,
ListTest
)
with
test_support
.
check_py3k_warnings
((
"dict inequality comparisons "
"not supported in 3.x"
,
DeprecationWarning
)):
test_support
.
run_unittest
(
DictTest
)
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
test_main
()
test_main
()
Lib/test/test_set.py
View file @
07627880
...
@@ -1345,6 +1345,10 @@ class TestOnlySetsOperator(TestOnlySetsInBinaryOps):
...
@@ -1345,6 +1345,10 @@ class TestOnlySetsOperator(TestOnlySetsInBinaryOps):
self
.
other
=
operator
.
add
self
.
other
=
operator
.
add
self
.
otherIsIterable
=
False
self
.
otherIsIterable
=
False
def
test_ge_gt_le_lt
(
self
):
with
test_support
.
check_py3k_warnings
():
super
(
TestOnlySetsOperator
,
self
).
test_ge_gt_le_lt
()
#------------------------------------------------------------------------------
#------------------------------------------------------------------------------
class
TestOnlySetsTuple
(
TestOnlySetsInBinaryOps
):
class
TestOnlySetsTuple
(
TestOnlySetsInBinaryOps
):
...
...
Lib/test/test_sets.py
View file @
07627880
#!/usr/bin/env python
#!/usr/bin/env python
import
warnings
warnings
.
filterwarnings
(
"ignore"
,
"the sets module is deprecated"
,
DeprecationWarning
,
"test
\
.
t
est_sets"
)
import
unittest
,
operator
,
copy
,
pickle
,
random
import
unittest
,
operator
,
copy
,
pickle
,
random
from
sets
import
Set
,
ImmutableSet
from
test
import
test_support
from
test
import
test_support
test_support
.
import_module
(
"sets"
,
deprecated
=
True
)
from
sets
import
Set
,
ImmutableSet
empty_set
=
Set
()
empty_set
=
Set
()
#==============================================================================
#==============================================================================
...
@@ -638,6 +636,10 @@ class TestOnlySetsOperator(TestOnlySetsInBinaryOps):
...
@@ -638,6 +636,10 @@ class TestOnlySetsOperator(TestOnlySetsInBinaryOps):
self
.
other
=
operator
.
add
self
.
other
=
operator
.
add
self
.
otherIsIterable
=
False
self
.
otherIsIterable
=
False
def
test_ge_gt_le_lt
(
self
):
with
test_support
.
check_py3k_warnings
():
super
(
TestOnlySetsOperator
,
self
).
test_ge_gt_le_lt
()
#------------------------------------------------------------------------------
#------------------------------------------------------------------------------
class
TestOnlySetsTuple
(
TestOnlySetsInBinaryOps
):
class
TestOnlySetsTuple
(
TestOnlySetsInBinaryOps
):
...
@@ -679,20 +681,16 @@ class TestCopying(unittest.TestCase):
...
@@ -679,20 +681,16 @@ class TestCopying(unittest.TestCase):
def
test_copy
(
self
):
def
test_copy
(
self
):
dup
=
self
.
set
.
copy
()
dup
=
self
.
set
.
copy
()
dup_list
=
list
(
dup
);
dup_list
.
sort
()
self
.
assertEqual
(
len
(
dup
),
len
(
self
.
set
))
set_list
=
list
(
self
.
set
);
set_list
.
sort
()
dup_list
=
sorted
(
dup
)
set_list
=
sorted
(
self
.
set
)
self
.
assertEqual
(
len
(
dup_list
),
len
(
set_list
))
self
.
assertEqual
(
len
(
dup_list
),
len
(
set_list
))
for
i
in
range
(
len
(
dup_list
)
):
for
i
,
el
in
enumerate
(
dup_list
):
self
.
assert
True
(
dup_list
[
i
]
is
set_list
[
i
])
self
.
assert
Is
(
el
,
set_list
[
i
])
def
test_deep_copy
(
self
):
def
test_deep_copy
(
self
):
dup
=
copy
.
deepcopy
(
self
.
set
)
dup
=
copy
.
deepcopy
(
self
.
set
)
##print type(dup), repr(dup)
self
.
assertSetEqual
(
dup
,
self
.
set
)
dup_list
=
list
(
dup
);
dup_list
.
sort
()
set_list
=
list
(
self
.
set
);
set_list
.
sort
()
self
.
assertEqual
(
len
(
dup_list
),
len
(
set_list
))
for
i
in
range
(
len
(
dup_list
)):
self
.
assertEqual
(
dup_list
[
i
],
set_list
[
i
])
#------------------------------------------------------------------------------
#------------------------------------------------------------------------------
...
@@ -712,6 +710,10 @@ class TestCopyingTriple(TestCopying):
...
@@ -712,6 +710,10 @@ class TestCopyingTriple(TestCopying):
def
setUp
(
self
):
def
setUp
(
self
):
self
.
set
=
Set
([
"zero"
,
0
,
None
])
self
.
set
=
Set
([
"zero"
,
0
,
None
])
def
test_copy
(
self
):
with
test_support
.
check_py3k_warnings
():
super
(
TestCopyingTriple
,
self
).
test_copy
()
#------------------------------------------------------------------------------
#------------------------------------------------------------------------------
class
TestCopyingTuple
(
TestCopying
):
class
TestCopyingTuple
(
TestCopying
):
...
...
Lib/test/test_slice.py
View file @
07627880
...
@@ -115,7 +115,8 @@ class SliceTest(unittest.TestCase):
...
@@ -115,7 +115,8 @@ class SliceTest(unittest.TestCase):
tmp
.
append
((
i
,
j
,
k
))
tmp
.
append
((
i
,
j
,
k
))
x
=
X
()
x
=
X
()
x
[
1
:
2
]
=
42
with
test_support
.
check_py3k_warnings
():
x
[
1
:
2
]
=
42
self
.
assertEquals
(
tmp
,
[(
1
,
2
,
42
)])
self
.
assertEquals
(
tmp
,
[(
1
,
2
,
42
)])
def
test_pickle
(
self
):
def
test_pickle
(
self
):
...
...
Lib/test/test_socket.py
View file @
07627880
...
@@ -123,8 +123,9 @@ class ThreadableTest:
...
@@ -123,8 +123,9 @@ class ThreadableTest:
self
.
server_ready
.
wait
()
self
.
server_ready
.
wait
()
self
.
client_ready
.
set
()
self
.
client_ready
.
set
()
self
.
clientSetUp
()
self
.
clientSetUp
()
if
not
callable
(
test_func
):
with
test_support
.
check_py3k_warnings
():
raise
TypeError
,
"test_func must be a callable function"
if
not
callable
(
test_func
):
raise
TypeError
(
"test_func must be a callable function."
)
try
:
try
:
test_func
()
test_func
()
except
Exception
,
strerror
:
except
Exception
,
strerror
:
...
@@ -132,7 +133,7 @@ class ThreadableTest:
...
@@ -132,7 +133,7 @@ class ThreadableTest:
self
.
clientTearDown
()
self
.
clientTearDown
()
def
clientSetUp
(
self
):
def
clientSetUp
(
self
):
raise
NotImplementedError
,
"clientSetUp must be implemented."
raise
NotImplementedError
(
"clientSetUp must be implemented."
)
def
clientTearDown
(
self
):
def
clientTearDown
(
self
):
self
.
done
.
set
()
self
.
done
.
set
()
...
@@ -282,8 +283,8 @@ class GeneralModuleTests(unittest.TestCase):
...
@@ -282,8 +283,8 @@ class GeneralModuleTests(unittest.TestCase):
orig
=
sys
.
getrefcount
(
__name__
)
orig
=
sys
.
getrefcount
(
__name__
)
socket
.
getnameinfo
(
__name__
,
0
)
socket
.
getnameinfo
(
__name__
,
0
)
except
TypeError
:
except
TypeError
:
if
sys
.
getrefcount
(
__name__
)
<>
orig
:
self
.
assertEqual
(
sys
.
getrefcount
(
__name__
),
orig
,
self
.
fail
(
"socket.getnameinfo loses a reference"
)
"socket.getnameinfo loses a reference"
)
def
testInterpreterCrash
(
self
):
def
testInterpreterCrash
(
self
):
# Making sure getnameinfo doesn't crash the interpreter
# Making sure getnameinfo doesn't crash the interpreter
...
@@ -1234,7 +1235,8 @@ class BufferIOTest(SocketConnectedTest):
...
@@ -1234,7 +1235,8 @@ class BufferIOTest(SocketConnectedTest):
self
.
assertEqual
(
msg
,
MSG
)
self
.
assertEqual
(
msg
,
MSG
)
def
_testRecvIntoArray
(
self
):
def
_testRecvIntoArray
(
self
):
buf
=
buffer
(
MSG
)
with
test_support
.
check_py3k_warnings
():
buf
=
buffer
(
MSG
)
self
.
serv_conn
.
send
(
buf
)
self
.
serv_conn
.
send
(
buf
)
def
testRecvIntoBytearray
(
self
):
def
testRecvIntoBytearray
(
self
):
...
@@ -1263,7 +1265,8 @@ class BufferIOTest(SocketConnectedTest):
...
@@ -1263,7 +1265,8 @@ class BufferIOTest(SocketConnectedTest):
self
.
assertEqual
(
msg
,
MSG
)
self
.
assertEqual
(
msg
,
MSG
)
def
_testRecvFromIntoArray
(
self
):
def
_testRecvFromIntoArray
(
self
):
buf
=
buffer
(
MSG
)
with
test_support
.
check_py3k_warnings
():
buf
=
buffer
(
MSG
)
self
.
serv_conn
.
send
(
buf
)
self
.
serv_conn
.
send
(
buf
)
def
testRecvFromIntoBytearray
(
self
):
def
testRecvFromIntoBytearray
(
self
):
...
...
Lib/test/test_sort.py
View file @
07627880
...
@@ -185,7 +185,7 @@ class TestDecorateSortUndecorate(unittest.TestCase):
...
@@ -185,7 +185,7 @@ class TestDecorateSortUndecorate(unittest.TestCase):
def
test_stability
(
self
):
def
test_stability
(
self
):
data
=
[(
random
.
randrange
(
100
),
i
)
for
i
in
xrange
(
200
)]
data
=
[(
random
.
randrange
(
100
),
i
)
for
i
in
xrange
(
200
)]
copy
=
data
[:]
copy
=
data
[:]
data
.
sort
(
key
=
lambda
(
x
,
y
):
x
)
# sort on the random first field
data
.
sort
(
key
=
lambda
x
:
x
[
0
])
# sort on the random first field
copy
.
sort
()
# sort using both fields
copy
.
sort
()
# sort using both fields
self
.
assertEqual
(
data
,
copy
)
# should get the same result
self
.
assertEqual
(
data
,
copy
)
# should get the same result
...
@@ -207,7 +207,7 @@ class TestDecorateSortUndecorate(unittest.TestCase):
...
@@ -207,7 +207,7 @@ class TestDecorateSortUndecorate(unittest.TestCase):
# Verify that the wrapper has been removed
# Verify that the wrapper has been removed
data
=
range
(
-
2
,
2
)
data
=
range
(
-
2
,
2
)
dup
=
data
[:]
dup
=
data
[:]
self
.
assertRaises
(
ZeroDivisionError
,
data
.
sort
,
None
,
lambda
x
:
1
/
x
)
self
.
assertRaises
(
ZeroDivisionError
,
data
.
sort
,
None
,
lambda
x
:
1
//
x
)
self
.
assertEqual
(
data
,
dup
)
self
.
assertEqual
(
data
,
dup
)
def
test_key_with_mutation
(
self
):
def
test_key_with_mutation
(
self
):
...
@@ -274,17 +274,19 @@ def test_main(verbose=None):
...
@@ -274,17 +274,19 @@ def test_main(verbose=None):
TestBugs
,
TestBugs
,
)
)
test_support
.
run_unittest
(
*
test_classes
)
with
test_support
.
check_py3k_warnings
(
(
"the cmp argument is not supported"
,
DeprecationWarning
)):
# verify reference counting
test_support
.
run_unittest
(
*
test_classes
)
if
verbose
and
hasattr
(
sys
,
"gettotalrefcount"
):
import
gc
# verify reference counting
counts
=
[
None
]
*
5
if
verbose
and
hasattr
(
sys
,
"gettotalrefcount"
):
for
i
in
xrange
(
len
(
counts
)):
import
gc
test_support
.
run_unittest
(
*
test_classes
)
counts
=
[
None
]
*
5
gc
.
collect
()
for
i
in
xrange
(
len
(
counts
)):
counts
[
i
]
=
sys
.
gettotalrefcount
()
test_support
.
run_unittest
(
*
test_classes
)
print
counts
gc
.
collect
()
counts
[
i
]
=
sys
.
gettotalrefcount
()
print
counts
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
test_main
(
verbose
=
True
)
test_main
(
verbose
=
True
)
Lib/test/test_ssl.py
View file @
07627880
...
@@ -805,7 +805,7 @@ else:
...
@@ -805,7 +805,7 @@ else:
if
test_support
.
verbose
:
if
test_support
.
verbose
:
sys
.
stdout
.
write
(
pprint
.
pformat
(
cert
)
+
'
\
n
'
)
sys
.
stdout
.
write
(
pprint
.
pformat
(
cert
)
+
'
\
n
'
)
sys
.
stdout
.
write
(
"Connection cipher is "
+
str
(
cipher
)
+
'.
\
n
'
)
sys
.
stdout
.
write
(
"Connection cipher is "
+
str
(
cipher
)
+
'.
\
n
'
)
if
not
cert
.
has_key
(
'subject'
)
:
if
'subject'
not
in
cert
:
raise
test_support
.
TestFailed
(
raise
test_support
.
TestFailed
(
"No subject field in certificate: %s."
%
"No subject field in certificate: %s."
%
pprint
.
pformat
(
cert
))
pprint
.
pformat
(
cert
))
...
@@ -967,7 +967,8 @@ else:
...
@@ -967,7 +967,8 @@ else:
# now fetch the same data from the HTTPS server
# now fetch the same data from the HTTPS server
url
=
'https://127.0.0.1:%d/%s'
%
(
url
=
'https://127.0.0.1:%d/%s'
%
(
server
.
port
,
os
.
path
.
split
(
CERTFILE
)[
1
])
server
.
port
,
os
.
path
.
split
(
CERTFILE
)[
1
])
f
=
urllib
.
urlopen
(
url
)
with
test_support
.
check_py3k_warnings
():
f
=
urllib
.
urlopen
(
url
)
dlen
=
f
.
info
().
getheader
(
"content-length"
)
dlen
=
f
.
info
().
getheader
(
"content-length"
)
if
dlen
and
(
int
(
dlen
)
>
0
):
if
dlen
and
(
int
(
dlen
)
>
0
):
d2
=
f
.
read
(
int
(
dlen
))
d2
=
f
.
read
(
int
(
dlen
))
...
...
Lib/test/test_syntax.py
View file @
07627880
...
@@ -552,7 +552,9 @@ class SyntaxTestCase(unittest.TestCase):
...
@@ -552,7 +552,9 @@ class SyntaxTestCase(unittest.TestCase):
def
test_main
():
def
test_main
():
test_support
.
run_unittest
(
SyntaxTestCase
)
test_support
.
run_unittest
(
SyntaxTestCase
)
from
test
import
test_syntax
from
test
import
test_syntax
test_support
.
run_doctest
(
test_syntax
,
verbosity
=
True
)
with
test_support
.
check_py3k_warnings
((
"backquote not supported"
,
SyntaxWarning
)):
test_support
.
run_doctest
(
test_syntax
,
verbosity
=
True
)
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
test_main
()
test_main
()
Lib/test/test_types.py
View file @
07627880
# Python test set -- part 6, built-in types
# Python test set -- part 6, built-in types
from
test.test_support
import
run_unittest
,
have_unicode
,
run_with_locale
from
test.test_support
import
run_unittest
,
have_unicode
,
run_with_locale
,
\
check_py3k_warnings
import
unittest
import
unittest
import
sys
import
sys
import
locale
import
locale
...
@@ -741,7 +742,10 @@ class TypesTests(unittest.TestCase):
...
@@ -741,7 +742,10 @@ class TypesTests(unittest.TestCase):
self
.
assertRaises
(
ValueError
,
format
,
0
,
','
+
code
)
self
.
assertRaises
(
ValueError
,
format
,
0
,
','
+
code
)
def
test_main
():
def
test_main
():
run_unittest
(
TypesTests
)
with
check_py3k_warnings
(
(
"buffer.. not supported"
,
DeprecationWarning
),
(
"classic long division"
,
DeprecationWarning
)):
run_unittest
(
TypesTests
)
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
test_main
()
test_main
()
Lib/test/test_undocumented_details.py
View file @
07627880
from
test.test_support
import
run_unittest
from
test.test_support
import
run_unittest
,
check_py3k_warnings
import
unittest
import
unittest
class
TestImplementationComparisons
(
unittest
.
TestCase
):
class
TestImplementationComparisons
(
unittest
.
TestCase
):
...
@@ -32,7 +32,8 @@ class TestImplementationComparisons(unittest.TestCase):
...
@@ -32,7 +32,8 @@ class TestImplementationComparisons(unittest.TestCase):
self
.
assertTrue
(
g_cell
!=
h_cell
)
self
.
assertTrue
(
g_cell
!=
h_cell
)
def
test_main
():
def
test_main
():
run_unittest
(
TestImplementationComparisons
)
with
check_py3k_warnings
():
run_unittest
(
TestImplementationComparisons
)
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
test_main
()
test_main
()
Lib/test/test_univnewlines2k.py
View file @
07627880
...
@@ -80,7 +80,8 @@ class TestGenericUnivNewlines(unittest.TestCase):
...
@@ -80,7 +80,8 @@ class TestGenericUnivNewlines(unittest.TestCase):
def
test_execfile
(
self
):
def
test_execfile
(
self
):
namespace
=
{}
namespace
=
{}
execfile
(
test_support
.
TESTFN
,
namespace
)
with
test_support
.
check_py3k_warnings
():
execfile
(
test_support
.
TESTFN
,
namespace
)
func
=
namespace
[
'line3'
]
func
=
namespace
[
'line3'
]
self
.
assertEqual
(
func
.
func_code
.
co_firstlineno
,
3
)
self
.
assertEqual
(
func
.
func_code
.
co_firstlineno
,
3
)
self
.
assertEqual
(
namespace
[
'line4'
],
FATX
)
self
.
assertEqual
(
namespace
[
'line4'
],
FATX
)
...
...
Lib/test/test_userdict.py
View file @
07627880
...
@@ -45,7 +45,7 @@ class UserDictTest(mapping_tests.TestHashMappingProtocol):
...
@@ -45,7 +45,7 @@ class UserDictTest(mapping_tests.TestHashMappingProtocol):
# Test __repr__
# Test __repr__
self
.
assertEqual
(
str
(
u0
),
str
(
d0
))
self
.
assertEqual
(
str
(
u0
),
str
(
d0
))
self
.
assertEqual
(
repr
(
u1
),
repr
(
d1
))
self
.
assertEqual
(
repr
(
u1
),
repr
(
d1
))
self
.
assertEqual
(
`u2`
,
`d2`
)
self
.
assertEqual
(
repr
(
u2
),
repr
(
d2
)
)
# Test __cmp__ and __len__
# Test __cmp__ and __len__
all
=
[
d0
,
d1
,
d2
,
u
,
u0
,
u1
,
u2
,
uu
,
uu0
,
uu1
,
uu2
]
all
=
[
d0
,
d1
,
d2
,
u
,
u0
,
u1
,
u2
,
uu
,
uu0
,
uu1
,
uu2
]
...
@@ -95,12 +95,13 @@ class UserDictTest(mapping_tests.TestHashMappingProtocol):
...
@@ -95,12 +95,13 @@ class UserDictTest(mapping_tests.TestHashMappingProtocol):
# Test has_key and "in".
# Test has_key and "in".
for
i
in
u2
.
keys
():
for
i
in
u2
.
keys
():
self
.
assertTrue
(
u2
.
has_key
(
i
))
self
.
assertIn
(
i
,
u2
)
self
.
assertIn
(
i
,
u2
)
self
.
assertEqual
(
u1
.
has_key
(
i
),
d1
.
has_key
(
i
))
self
.
assertEqual
(
i
in
u1
,
i
in
d1
)
self
.
assertEqual
(
i
in
u1
,
i
in
d1
)
self
.
assertEqual
(
u0
.
has_key
(
i
),
d0
.
has_key
(
i
))
self
.
assertEqual
(
i
in
u0
,
i
in
d0
)
self
.
assertEqual
(
i
in
u0
,
i
in
d0
)
with
test_support
.
check_py3k_warnings
():
self
.
assertTrue
(
u2
.
has_key
(
i
))
self
.
assertEqual
(
u1
.
has_key
(
i
),
d1
.
has_key
(
i
))
self
.
assertEqual
(
u0
.
has_key
(
i
),
d0
.
has_key
(
i
))
# Test update
# Test update
t
=
UserDict
.
UserDict
()
t
=
UserDict
.
UserDict
()
...
...
Lib/test/test_userlist.py
View file @
07627880
...
@@ -53,7 +53,9 @@ class UserListTest(list_tests.CommonTest):
...
@@ -53,7 +53,9 @@ class UserListTest(list_tests.CommonTest):
self
.
assertEqual
(
iter
(
T
((
1
,
2
))).
next
(),
"0!!!"
)
self
.
assertEqual
(
iter
(
T
((
1
,
2
))).
next
(),
"0!!!"
)
def
test_main
():
def
test_main
():
test_support
.
run_unittest
(
UserListTest
)
with
test_support
.
check_py3k_warnings
(
(
".+__(get|set|del)slice__ has been removed"
,
DeprecationWarning
)):
test_support
.
run_unittest
(
UserListTest
)
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
test_main
()
test_main
()
Lib/test/test_weakref.py
View file @
07627880
...
@@ -54,10 +54,10 @@ class ReferencesTestCase(TestBase):
...
@@ -54,10 +54,10 @@ class ReferencesTestCase(TestBase):
# Live reference:
# Live reference:
o
=
C
()
o
=
C
()
wr
=
weakref
.
ref
(
o
)
wr
=
weakref
.
ref
(
o
)
`wr`
repr
(
wr
)
# Dead reference:
# Dead reference:
del
o
del
o
`wr`
repr
(
wr
)
def
test_basic_callback
(
self
):
def
test_basic_callback
(
self
):
self
.
check_basic_callback
(
C
)
self
.
check_basic_callback
(
C
)
...
@@ -169,7 +169,8 @@ class ReferencesTestCase(TestBase):
...
@@ -169,7 +169,8 @@ class ReferencesTestCase(TestBase):
p
.
append
(
12
)
p
.
append
(
12
)
self
.
assertEqual
(
len
(
L
),
1
)
self
.
assertEqual
(
len
(
L
),
1
)
self
.
assertTrue
(
p
,
"proxy for non-empty UserList should be true"
)
self
.
assertTrue
(
p
,
"proxy for non-empty UserList should be true"
)
p
[:]
=
[
2
,
3
]
with
test_support
.
check_py3k_warnings
():
p
[:]
=
[
2
,
3
]
self
.
assertEqual
(
len
(
L
),
2
)
self
.
assertEqual
(
len
(
L
),
2
)
self
.
assertEqual
(
len
(
p
),
2
)
self
.
assertEqual
(
len
(
p
),
2
)
self
.
assertIn
(
3
,
p
,
"proxy didn't support __contains__() properly"
)
self
.
assertIn
(
3
,
p
,
"proxy didn't support __contains__() properly"
)
...
@@ -182,10 +183,11 @@ class ReferencesTestCase(TestBase):
...
@@ -182,10 +183,11 @@ class ReferencesTestCase(TestBase):
## self.assertEqual(repr(L2), repr(p2))
## self.assertEqual(repr(L2), repr(p2))
L3
=
UserList
.
UserList
(
range
(
10
))
L3
=
UserList
.
UserList
(
range
(
10
))
p3
=
weakref
.
proxy
(
L3
)
p3
=
weakref
.
proxy
(
L3
)
self
.
assertEqual
(
L3
[:],
p3
[:])
with
test_support
.
check_py3k_warnings
():
self
.
assertEqual
(
L3
[
5
:],
p3
[
5
:])
self
.
assertEqual
(
L3
[:],
p3
[:])
self
.
assertEqual
(
L3
[:
5
],
p3
[:
5
])
self
.
assertEqual
(
L3
[
5
:],
p3
[
5
:])
self
.
assertEqual
(
L3
[
2
:
5
],
p3
[
2
:
5
])
self
.
assertEqual
(
L3
[:
5
],
p3
[:
5
])
self
.
assertEqual
(
L3
[
2
:
5
],
p3
[
2
:
5
])
def
test_proxy_unicode
(
self
):
def
test_proxy_unicode
(
self
):
# See bug 5037
# See bug 5037
...
@@ -831,7 +833,7 @@ class MappingTestCase(TestBase):
...
@@ -831,7 +833,7 @@ class MappingTestCase(TestBase):
def
test_weak_keys
(
self
):
def
test_weak_keys
(
self
):
#
#
# This exercises d.copy(), d.items(), d[] = v, d[], del d[],
# This exercises d.copy(), d.items(), d[] = v, d[], del d[],
# len(d),
d.has_key()
.
# len(d),
in d
.
#
#
dict
,
objects
=
self
.
make_weak_keyed_dict
()
dict
,
objects
=
self
.
make_weak_keyed_dict
()
for
o
in
objects
:
for
o
in
objects
:
...
@@ -853,8 +855,8 @@ class MappingTestCase(TestBase):
...
@@ -853,8 +855,8 @@ class MappingTestCase(TestBase):
"deleting the keys did not clear the dictionary"
)
"deleting the keys did not clear the dictionary"
)
o
=
Object
(
42
)
o
=
Object
(
42
)
dict
[
o
]
=
"What is the meaning of the universe?"
dict
[
o
]
=
"What is the meaning of the universe?"
self
.
assert
True
(
dict
.
has_key
(
o
)
)
self
.
assert
In
(
o
,
dict
)
self
.
assert
True
(
not
dict
.
has_key
(
34
)
)
self
.
assert
NotIn
(
34
,
dict
)
def
test_weak_keyed_iters
(
self
):
def
test_weak_keyed_iters
(
self
):
dict
,
objects
=
self
.
make_weak_keyed_dict
()
dict
,
objects
=
self
.
make_weak_keyed_dict
()
...
@@ -866,7 +868,6 @@ class MappingTestCase(TestBase):
...
@@ -866,7 +868,6 @@ class MappingTestCase(TestBase):
objects2
=
list
(
objects
)
objects2
=
list
(
objects
)
for
wr
in
refs
:
for
wr
in
refs
:
ob
=
wr
()
ob
=
wr
()
self
.
assertTrue
(
dict
.
has_key
(
ob
))
self
.
assertIn
(
ob
,
dict
)
self
.
assertIn
(
ob
,
dict
)
self
.
assertEqual
(
ob
.
arg
,
dict
[
ob
])
self
.
assertEqual
(
ob
.
arg
,
dict
[
ob
])
objects2
.
remove
(
ob
)
objects2
.
remove
(
ob
)
...
@@ -877,7 +878,6 @@ class MappingTestCase(TestBase):
...
@@ -877,7 +878,6 @@ class MappingTestCase(TestBase):
self
.
assertEqual
(
len
(
list
(
dict
.
iterkeyrefs
())),
len
(
objects
))
self
.
assertEqual
(
len
(
list
(
dict
.
iterkeyrefs
())),
len
(
objects
))
for
wr
in
dict
.
iterkeyrefs
():
for
wr
in
dict
.
iterkeyrefs
():
ob
=
wr
()
ob
=
wr
()
self
.
assertTrue
(
dict
.
has_key
(
ob
))
self
.
assertIn
(
ob
,
dict
)
self
.
assertIn
(
ob
,
dict
)
self
.
assertEqual
(
ob
.
arg
,
dict
[
ob
])
self
.
assertEqual
(
ob
.
arg
,
dict
[
ob
])
objects2
.
remove
(
ob
)
objects2
.
remove
(
ob
)
...
@@ -991,16 +991,16 @@ class MappingTestCase(TestBase):
...
@@ -991,16 +991,16 @@ class MappingTestCase(TestBase):
" -- value parameters must be distinct objects"
)
" -- value parameters must be distinct objects"
)
weakdict
=
klass
()
weakdict
=
klass
()
o
=
weakdict
.
setdefault
(
key
,
value1
)
o
=
weakdict
.
setdefault
(
key
,
value1
)
self
.
assert
True
(
o
is
value1
)
self
.
assert
Is
(
o
,
value1
)
self
.
assert
True
(
weakdict
.
has_key
(
key
)
)
self
.
assert
In
(
key
,
weakdict
)
self
.
assert
True
(
weakdict
.
get
(
key
)
is
value1
)
self
.
assert
Is
(
weakdict
.
get
(
key
),
value1
)
self
.
assert
True
(
weakdict
[
key
]
is
value1
)
self
.
assert
Is
(
weakdict
[
key
],
value1
)
o
=
weakdict
.
setdefault
(
key
,
value2
)
o
=
weakdict
.
setdefault
(
key
,
value2
)
self
.
assert
True
(
o
is
value1
)
self
.
assert
Is
(
o
,
value1
)
self
.
assert
True
(
weakdict
.
has_key
(
key
)
)
self
.
assert
In
(
key
,
weakdict
)
self
.
assert
True
(
weakdict
.
get
(
key
)
is
value1
)
self
.
assert
Is
(
weakdict
.
get
(
key
),
value1
)
self
.
assert
True
(
weakdict
[
key
]
is
value1
)
self
.
assert
Is
(
weakdict
[
key
],
value1
)
def
test_weak_valued_dict_setdefault
(
self
):
def
test_weak_valued_dict_setdefault
(
self
):
self
.
check_setdefault
(
weakref
.
WeakValueDictionary
,
self
.
check_setdefault
(
weakref
.
WeakValueDictionary
,
...
@@ -1012,24 +1012,24 @@ class MappingTestCase(TestBase):
...
@@ -1012,24 +1012,24 @@ class MappingTestCase(TestBase):
def
check_update
(
self
,
klass
,
dict
):
def
check_update
(
self
,
klass
,
dict
):
#
#
# This exercises d.update(), len(d), d.keys(),
d.has_key()
,
# This exercises d.update(), len(d), d.keys(),
in d
,
# d.get(), d[].
# d.get(), d[].
#
#
weakdict
=
klass
()
weakdict
=
klass
()
weakdict
.
update
(
dict
)
weakdict
.
update
(
dict
)
self
.
assert
True
(
len
(
weakdict
)
==
len
(
dict
))
self
.
assert
Equal
(
len
(
weakdict
),
len
(
dict
))
for
k
in
weakdict
.
keys
():
for
k
in
weakdict
.
keys
():
self
.
assert
True
(
dict
.
has_key
(
k
)
,
self
.
assert
In
(
k
,
dict
,
"mysterious new key appeared in weak dict"
)
"mysterious new key appeared in weak dict"
)
v
=
dict
.
get
(
k
)
v
=
dict
.
get
(
k
)
self
.
assert
True
(
v
is
weakdict
[
k
])
self
.
assert
Is
(
v
,
weakdict
[
k
])
self
.
assert
True
(
v
is
weakdict
.
get
(
k
))
self
.
assert
Is
(
v
,
weakdict
.
get
(
k
))
for
k
in
dict
.
keys
():
for
k
in
dict
.
keys
():
self
.
assert
True
(
weakdict
.
has_key
(
k
)
,
self
.
assert
In
(
k
,
weakdict
,
"original key disappeared in weak dict"
)
"original key disappeared in weak dict"
)
v
=
dict
[
k
]
v
=
dict
[
k
]
self
.
assert
True
(
v
is
weakdict
[
k
])
self
.
assert
Is
(
v
,
weakdict
[
k
])
self
.
assert
True
(
v
is
weakdict
.
get
(
k
))
self
.
assert
Is
(
v
,
weakdict
.
get
(
k
))
def
test_weak_valued_dict_update
(
self
):
def
test_weak_valued_dict_update
(
self
):
self
.
check_update
(
weakref
.
WeakValueDictionary
,
self
.
check_update
(
weakref
.
WeakValueDictionary
,
...
...
Lib/test/test_zipimport_support.py
View file @
07627880
...
@@ -13,6 +13,7 @@ import doctest
...
@@ -13,6 +13,7 @@ import doctest
import
inspect
import
inspect
import
linecache
import
linecache
import
pdb
import
pdb
import
warnings
from
test.script_helper
import
(
spawn_python
,
kill_python
,
run_python
,
from
test.script_helper
import
(
spawn_python
,
kill_python
,
run_python
,
temp_dir
,
make_script
,
make_zip_script
)
temp_dir
,
make_script
,
make_zip_script
)
...
@@ -166,8 +167,15 @@ class ZipSupportTests(ImportHooksBaseTestCase):
...
@@ -166,8 +167,15 @@ class ZipSupportTests(ImportHooksBaseTestCase):
test_zipped_doctest
.
test_testfile
,
test_zipped_doctest
.
test_testfile
,
test_zipped_doctest
.
test_unittest_reportflags
,
test_zipped_doctest
.
test_unittest_reportflags
,
]
]
for
obj
in
known_good_tests
:
# Needed for test_DocTestParser and test_debug
_run_object_doctest
(
obj
,
test_zipped_doctest
)
with
test
.
test_support
.
check_py3k_warnings
(
(
"backquote not supported"
,
SyntaxWarning
),
(
"execfile.. not supported"
,
DeprecationWarning
)):
# Ignore all warnings about the use of class Tester in this module.
warnings
.
filterwarnings
(
"ignore"
,
"class Tester is deprecated"
,
DeprecationWarning
)
for
obj
in
known_good_tests
:
_run_object_doctest
(
obj
,
test_zipped_doctest
)
def
test_doctest_main_issue4197
(
self
):
def
test_doctest_main_issue4197
(
self
):
test_src
=
textwrap
.
dedent
(
"""
\
test_src
=
textwrap
.
dedent
(
"""
\
...
...
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