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
07627880
Commit
07627880
authored
15 years ago
by
Florent Xicluna
Browse files
Options
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
20 changed files
with
150 additions
and
89 deletions
+150
-89
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
No files found.
Lib/test/list_tests.py
View file @
07627880
...
...
@@ -36,7 +36,7 @@ class CommonTest(seq_tests.CommonTest):
self
.
assertEqual
(
str
(
a0
),
str
(
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
(
repr
(
a2
),
"[0, 1, 2]"
)
...
...
@@ -421,6 +421,11 @@ class CommonTest(seq_tests.CommonTest):
self
.
assertRaises
(
TypeError
,
u
.
reverse
,
42
)
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
.
sort
()
self
.
assertEqual
(
u
,
[
0
,
1
])
...
...
This diff is collapsed.
Click to expand it.
Lib/test/mapping_tests.py
View file @
07627880
# tests common to dict and UserDict
import
unittest
import
UserDict
import
test_support
class
BasicTestMappingProtocol
(
unittest
.
TestCase
):
...
...
@@ -54,13 +55,17 @@ class BasicTestMappingProtocol(unittest.TestCase):
#len
self
.
assertEqual
(
len
(
p
),
0
)
self
.
assertEqual
(
len
(
d
),
len
(
self
.
reference
))
#
has_key
#
in
for
k
in
self
.
reference
:
self
.
assertTrue
(
d
.
has_key
(
k
))
self
.
assertIn
(
k
,
d
)
for
k
in
self
.
other
:
self
.
assertFalse
(
d
.
has_key
(
k
))
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
self
.
assertEqual
(
cmp
(
p
,
p
),
0
)
self
.
assertEqual
(
cmp
(
d
,
d
),
0
)
...
...
This diff is collapsed.
Click to expand it.
Lib/test/test_StringIO.py
View file @
07627880
...
...
@@ -137,12 +137,10 @@ class TestBuffercStringIO(TestcStringIO):
def
test_main
():
test_support
.
run_unittest
(
TestStringIO
,
TestcStringIO
,
TestBufferStringIO
,
TestBuffercStringIO
)
test_support
.
run_unittest
(
TestStringIO
,
TestcStringIO
)
with
test_support
.
check_py3k_warnings
((
"buffer.. not supported"
,
DeprecationWarning
)):
test_support
.
run_unittest
(
TestBufferStringIO
,
TestBuffercStringIO
)
if
__name__
==
'__main__'
:
test_main
()
This diff is collapsed.
Click to expand it.
Lib/test/test_array.py
View file @
07627880
...
...
@@ -749,7 +749,8 @@ class BaseTest(unittest.TestCase):
def
test_buffer
(
self
):
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
])
def
test_weakref
(
self
):
...
...
This diff is collapsed.
Click to expand it.
Lib/test/test_ast.py
View file @
07627880
...
...
@@ -302,7 +302,9 @@ class ASTHelpers_Test(unittest.TestCase):
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
():
if
__name__
!=
'__main__'
:
...
...
This diff is collapsed.
Click to expand it.
Lib/test/test_augassign.py
View file @
07627880
# Augmented assignment test.
from
test.test_support
import
run_unittest
from
test.test_support
import
run_unittest
,
check_py3k_warnings
import
unittest
...
...
@@ -324,7 +324,8 @@ __ilshift__ called
'''
.
splitlines
())
def
test_main
():
run_unittest
(
AugAssignTest
)
with
check_py3k_warnings
((
"classic int division"
,
DeprecationWarning
)):
run_unittest
(
AugAssignTest
)
if
__name__
==
'__main__'
:
test_main
()
This diff is collapsed.
Click to expand it.
Lib/test/test_bigmem.py
View file @
07627880
...
...
@@ -97,21 +97,21 @@ class StrTest(unittest.TestCase):
def
test_encode
(
self
,
size
):
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
):
try
:
return
self
.
basic_encode_test
(
size
,
'raw_unicode_escape'
)
except
MemoryError
:
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
):
try
:
return
self
.
basic_encode_test
(
size
,
'utf7'
)
except
MemoryError
:
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
):
try
:
return
self
.
basic_encode_test
(
size
,
'utf32'
,
expectedsize
=
4
*
size
+
4
)
...
...
@@ -122,7 +122,7 @@ class StrTest(unittest.TestCase):
def
test_decodeascii
(
self
,
size
):
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
):
try
:
s
=
u
"
\uAAAA
"
*
size
...
...
@@ -516,7 +516,7 @@ class StrTest(unittest.TestCase):
self
.
assertEquals
(
s
.
count
(
'
\\
'
),
size
)
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
):
s
=
u
"
\uAAAA
"
*
size
self
.
assertTrue
(
len
(
repr
(
s
))
>
size
)
...
...
@@ -1053,7 +1053,8 @@ class BufferTest(unittest.TestCase):
@
precisionbigmemtest
(
size
=
_1G
,
memuse
=
4
)
def
test_repeat
(
self
,
size
):
try
:
b
=
buffer
(
"AAAA"
)
*
size
with
test_support
.
check_py3k_warnings
():
b
=
buffer
(
"AAAA"
)
*
size
except
MemoryError
:
pass
# acceptable on 32-bit
else
:
...
...
This diff is collapsed.
Click to expand it.
Lib/test/test_bool.py
View file @
07627880
...
...
@@ -85,10 +85,10 @@ class BoolTest(unittest.TestCase):
self
.
assertEqual
(
False
*
1
,
0
)
self
.
assertIsNot
(
False
*
1
,
False
)
self
.
assertEqual
(
True
/
1
,
1
)
self
.
assertIsNot
(
True
/
1
,
True
)
self
.
assertEqual
(
False
/
1
,
0
)
self
.
assertIsNot
(
False
/
1
,
False
)
self
.
assertEqual
(
True
/
/
1
,
1
)
self
.
assertIsNot
(
True
/
/
1
,
True
)
self
.
assertEqual
(
False
/
/
1
,
0
)
self
.
assertIsNot
(
False
/
/
1
,
False
)
for
b
in
False
,
True
:
for
i
in
0
,
1
,
2
:
...
...
@@ -162,8 +162,9 @@ class BoolTest(unittest.TestCase):
self
.
assertIs
(
hasattr
([],
"wobble"
),
False
)
def
test_callable
(
self
):
self
.
assertIs
(
callable
(
len
),
True
)
self
.
assertIs
(
callable
(
1
),
False
)
with
test_support
.
check_py3k_warnings
():
self
.
assertIs
(
callable
(
len
),
True
)
self
.
assertIs
(
callable
(
1
),
False
)
def
test_isinstance
(
self
):
self
.
assertIs
(
isinstance
(
True
,
bool
),
True
)
...
...
@@ -178,8 +179,11 @@ class BoolTest(unittest.TestCase):
self
.
assertIs
(
issubclass
(
int
,
bool
),
False
)
def
test_haskey
(
self
):
self
.
assertIs
({}.
has_key
(
1
),
False
)
self
.
assertIs
({
1
:
1
}.
has_key
(
1
),
True
)
self
.
assertIs
(
1
in
{},
False
)
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
):
self
.
assertIs
(
"xyz"
.
endswith
(
"z"
),
True
)
...
...
@@ -251,8 +255,9 @@ class BoolTest(unittest.TestCase):
import
operator
self
.
assertIs
(
operator
.
truth
(
0
),
False
)
self
.
assertIs
(
operator
.
truth
(
1
),
True
)
self
.
assertIs
(
operator
.
isCallable
(
0
),
False
)
self
.
assertIs
(
operator
.
isCallable
(
len
),
True
)
with
test_support
.
check_py3k_warnings
():
self
.
assertIs
(
operator
.
isCallable
(
0
),
False
)
self
.
assertIs
(
operator
.
isCallable
(
len
),
True
)
self
.
assertIs
(
operator
.
isNumberType
(
None
),
False
)
self
.
assertIs
(
operator
.
isNumberType
(
0
),
True
)
self
.
assertIs
(
operator
.
not_
(
1
),
False
)
...
...
This diff is collapsed.
Click to expand it.
Lib/test/test_buffer.py
View file @
07627880
...
...
@@ -23,7 +23,9 @@ class BufferTests(unittest.TestCase):
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__"
:
test_main
()
This diff is collapsed.
Click to expand it.
Lib/test/test_builtin.py
View file @
07627880
...
...
@@ -3,14 +3,10 @@
import
platform
import
unittest
from
test.test_support
import
fcmp
,
have_unicode
,
TESTFN
,
unlink
,
\
run_unittest
run_unittest
,
check_py3k_warnings
from
operator
import
neg
import
sys
,
warnings
,
cStringIO
,
random
,
UserDict
warnings
.
filterwarnings
(
"ignore"
,
"hex../oct.. of negative int"
,
FutureWarning
,
__name__
)
warnings
.
filterwarnings
(
"ignore"
,
"integer argument expected"
,
DeprecationWarning
,
"unittest"
)
import
sys
,
cStringIO
,
random
,
UserDict
# count the number of test runs.
# used to skip running test_execfile() multiple times
...
...
@@ -419,7 +415,9 @@ class BuiltinTest(unittest.TestCase):
f
.
write
(
'z = z+1
\n
'
)
f
.
write
(
'z = z*2
\n
'
)
f
.
close
()
execfile
(
TESTFN
)
with
check_py3k_warnings
((
"execfile.. not supported in 3.x"
,
DeprecationWarning
)):
execfile
(
TESTFN
)
def
test_execfile
(
self
):
global
numruns
...
...
@@ -1542,17 +1540,24 @@ class TestSorted(unittest.TestCase):
data
=
'The quick Brown fox Jumped over The lazy Dog'
.
split
()
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
):
test_classes
=
(
BuiltinTest
,
TestSorted
)
run_unittest
(
*
test_classes
)
_
run_unittest
(
*
test_classes
)
# verify reference counting
if
verbose
and
hasattr
(
sys
,
"gettotalrefcount"
):
import
gc
counts
=
[
None
]
*
5
for
i
in
xrange
(
len
(
counts
)):
run_unittest
(
*
test_classes
)
_
run_unittest
(
*
test_classes
)
gc
.
collect
()
counts
[
i
]
=
sys
.
gettotalrefcount
()
print
counts
...
...
This diff is collapsed.
Click to expand it.
Lib/test/test_call.py
View file @
07627880
...
...
@@ -12,7 +12,8 @@ class CFunctionCalls(unittest.TestCase):
self
.
assertRaises
(
TypeError
,
{}.
has_key
)
def
test_varargs1
(
self
):
{}.
has_key
(
0
)
with
test_support
.
check_py3k_warnings
():
{}.
has_key
(
0
)
def
test_varargs2
(
self
):
self
.
assertRaises
(
TypeError
,
{}.
has_key
,
0
,
1
)
...
...
@@ -24,11 +25,13 @@ class CFunctionCalls(unittest.TestCase):
pass
def
test_varargs1_ext
(
self
):
{}.
has_key
(
*
(
0
,))
with
test_support
.
check_py3k_warnings
():
{}.
has_key
(
*
(
0
,))
def
test_varargs2_ext
(
self
):
try
:
{}.
has_key
(
*
(
1
,
2
))
with
test_support
.
check_py3k_warnings
():
{}.
has_key
(
*
(
1
,
2
))
except
TypeError
:
pass
else
:
...
...
This diff is collapsed.
Click to expand it.
Lib/test/test_class.py
View file @
07627880
...
...
@@ -407,7 +407,7 @@ class ClassTests(unittest.TestCase):
self
.
assertCallStack
([(
"__coerce__"
,
(
testme
,
1
)),
(
'__cmp__'
,
(
testme
,
1
))])
callLst
[:]
=
[]
testme
<>
1
# XXX kill this in py3k
eval
(
'
testme <> 1
'
)
# XXX kill this in py3k
self
.
assertCallStack
([(
"__coerce__"
,
(
testme
,
1
)),
(
'__cmp__'
,
(
testme
,
1
))])
callLst
[:]
=
[]
...
...
@@ -427,7 +427,7 @@ class ClassTests(unittest.TestCase):
self
.
assertCallStack
([(
"__coerce__"
,
(
testme
,
1
)),
(
'__cmp__'
,
(
1
,
testme
))])
callLst
[:]
=
[]
1
<>
testme
eval
(
'
1 <> testme
'
)
self
.
assertCallStack
([(
"__coerce__"
,
(
testme
,
1
)),
(
'__cmp__'
,
(
1
,
testme
))])
callLst
[:]
=
[]
...
...
@@ -616,7 +616,11 @@ class ClassTests(unittest.TestCase):
hash
(
a
.
f
)
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__'
:
test_main
()
This diff is collapsed.
Click to expand it.
Lib/test/test_ctypes.py
View file @
07627880
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
import_module
(
'_ctypes'
)
import
ctypes.test
def
test_main
():
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
))
with
check_py3k_warnings
((
"buffer.. not supported"
,
DeprecationWarning
),
(
"classic (int|long) division"
,
DeprecationWarning
)):
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__"
:
test_main
()
This diff is collapsed.
Click to expand it.
Lib/test/test_descr.py
View file @
07627880
...
...
@@ -4622,9 +4622,14 @@ class PTypesLongInitTest(unittest.TestCase):
def
test_main
():
# Run all local test cases, with PTypesLongInitTest first.
test_support
.
run_unittest
(
PTypesLongInitTest
,
OperatorsTest
,
ClassPropertiesAndMethods
,
DictProxyTests
)
with
test_support
.
check_py3k_warnings
(
(
"classic (int|long) division"
,
DeprecationWarning
),
(
"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__"
:
test_main
()
This diff is collapsed.
Click to expand it.
Lib/test/test_doctest.py
View file @
07627880
...
...
@@ -2169,7 +2169,7 @@ We don't want `-v` in sys.argv for these tests.
>>> doctest.master = None # Reset master.
(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.)
Globals may be specified with the `globs` and `extraglobs` parameters:
...
...
@@ -2333,12 +2333,6 @@ bothering with the current sys.stdout encoding.
# that these use the deprecated doctest.Tester, so should go away (or
# 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
"""
>>> from doctest import Tester
>>> t = Tester(globs={'x': 42}, verbose=0)
...
...
@@ -2462,9 +2456,16 @@ def old_test4(): """
def
test_main
():
# Check the doctest cases in doctest itself:
test_support
.
run_doctest
(
doctest
,
verbosity
=
True
)
# Check the doctest cases defined here:
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
def
test_coverage
(
coverdir
):
...
...
This diff is collapsed.
Click to expand it.
Lib/test/test_heapq.py
View file @
07627880
...
...
@@ -356,7 +356,10 @@ class TestErrorHandling(unittest.TestCase):
for
f
in
(
self
.
module
.
nlargest
,
self
.
module
.
nsmallest
):
for
s
in
(
"123"
,
""
,
range
(
1000
),
(
'do'
,
1.2
),
xrange
(
2000
,
2200
,
5
)):
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
.
assertRaises
(
TypeError
,
f
,
2
,
X
(
s
))
self
.
assertRaises
(
TypeError
,
f
,
2
,
N
(
s
))
...
...
This diff is collapsed.
Click to expand it.
Lib/test/test_inspect.py
View file @
07627880
...
...
@@ -4,10 +4,13 @@ import unittest
import
inspect
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
from
test
import
inspect_fodder2
as
mod2
with
check_py3k_warnings
(
(
"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
import
unicodedata
...
...
@@ -29,7 +32,7 @@ if modfile.endswith(('c', 'o')):
import
__builtin__
try
:
1
/
0
1
//
0
except
:
tb
=
sys
.
exc_traceback
...
...
@@ -420,11 +423,14 @@ class TestClassesAndFunctions(unittest.TestCase):
self
.
assertArgSpecEquals
(
A
.
m
,
[
'self'
])
def
test_getargspec_sublistofone
(
self
):
def
sublistOfOne
((
foo
,)):
return
1
self
.
assertArgSpecEquals
(
sublistOfOne
,
[[
'foo'
]])
def
fakeSublistOfOne
((
foo
)):
return
1
self
.
assertArgSpecEquals
(
fakeSublistOfOne
,
[
'foo'
])
with
check_py3k_warnings
(
(
"tuple parameter unpacking has been removed"
,
SyntaxWarning
),
(
"parenthesized argument names are invalid"
,
SyntaxWarning
)):
exec
'def sublistOfOne((foo,)): return 1'
self
.
assertArgSpecEquals
(
sublistOfOne
,
[[
'foo'
]])
exec
'def fakeSublistOfOne((foo)): return 1'
self
.
assertArgSpecEquals
(
fakeSublistOfOne
,
[
'foo'
])
def
test_classify_oldstyle
(
self
):
class
A
:
...
...
This diff is collapsed.
Click to expand it.
Lib/test/test_iter.py
View file @
07627880
# Test iterators.
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)
TRIPLETS
=
[(
0
,
0
,
0
),
(
0
,
0
,
1
),
(
0
,
0
,
2
),
...
...
@@ -396,21 +397,24 @@ class TestCase(unittest.TestCase):
# Test map()'s use of iterators.
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
))
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
())
dkeys
=
d
.
keys
()
expected
=
[(
i
<
len
(
d
)
and
dkeys
[
i
]
or
None
,
i
,
i
<
len
(
d
)
and
dkeys
[
i
]
or
None
)
for
i
in
range
(
5
)]
self
.
assertEqual
(
map
(
None
,
d
,
SequenceClass
(
5
),
iter
(
d
.
iterkeys
())),
expected
)
# Deprecated map(None, ...)
with
check_py3k_warnings
():
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"
)
try
:
...
...
@@ -506,7 +510,11 @@ class TestCase(unittest.TestCase):
self
.
assertEqual
(
zip
(
x
,
y
),
expected
)
# 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
self
.
assertEqual
(
reduce
(
add
,
SequenceClass
(
5
)),
10
)
self
.
assertEqual
(
reduce
(
add
,
SequenceClass
(
5
),
42
),
52
)
...
...
This diff is collapsed.
Click to expand it.
Lib/test/test_long.py
View file @
07627880
...
...
@@ -574,11 +574,12 @@ class LongTest(unittest.TestCase):
def
__getslice__
(
self
,
i
,
j
):
return
i
,
j
self
.
assertEqual
(
X
()[
-
5L
:
7L
],
(
-
5
,
7
))
# use the clamping effect to test the smallest and largest longs
# that fit a Py_ssize_t
slicemin
,
slicemax
=
X
()[
-
2L
**
100
:
2L
**
100
]
self
.
assertEqual
(
X
()[
slicemin
:
slicemax
],
(
slicemin
,
slicemax
))
with
test_support
.
check_py3k_warnings
():
self
.
assertEqual
(
X
()[
-
5L
:
7L
],
(
-
5
,
7
))
# use the clamping effect to test the smallest and largest longs
# that fit a Py_ssize_t
slicemin
,
slicemax
=
X
()[
-
2L
**
100
:
2L
**
100
]
self
.
assertEqual
(
X
()[
slicemin
:
slicemax
],
(
slicemin
,
slicemax
))
# ----------------------------------- tests of auto int->long conversion
...
...
@@ -616,8 +617,9 @@ class LongTest(unittest.TestCase):
checkit
(
x
,
'*'
,
y
)
if
y
:
expected
=
longx
/
longy
got
=
x
/
y
with
test_support
.
check_py3k_warnings
():
expected
=
longx
/
longy
got
=
x
/
y
checkit
(
x
,
'/'
,
y
)
expected
=
longx
//
longy
...
...
This diff is collapsed.
Click to expand it.
Lib/test/test_marshal.py
View file @
07627880
...
...
@@ -129,7 +129,9 @@ class StringTestCase(unittest.TestCase):
def
test_buffer
(
self
):
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
))
self
.
assertEqual
(
s
,
new
)
marshal
.
dump
(
b
,
file
(
test_support
.
TESTFN
,
"wb"
))
...
...
This diff is collapsed.
Click to expand it.
Prev
1
2
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