mirror of
https://github.com/python/cpython.git
synced 2025-10-02 13:22:19 +00:00
Fix deprecation warnings in test_scope.py
This commit is contained in:
parent
90a732c23c
commit
ee1e2c90dd
1 changed files with 14 additions and 11 deletions
|
@ -1,9 +1,7 @@
|
||||||
import unittest
|
import unittest
|
||||||
from test.test_support import check_syntax_error, run_unittest
|
from test.test_support import (check_syntax_error, _check_py3k_warnings,
|
||||||
|
check_warnings, run_unittest)
|
||||||
|
|
||||||
import warnings
|
|
||||||
warnings.filterwarnings("ignore", r"import \*", SyntaxWarning, "<test string>")
|
|
||||||
warnings.filterwarnings("ignore", r"import \*", SyntaxWarning, "<string>")
|
|
||||||
|
|
||||||
class ScopeTests(unittest.TestCase):
|
class ScopeTests(unittest.TestCase):
|
||||||
|
|
||||||
|
@ -332,11 +330,14 @@ else:
|
||||||
|
|
||||||
self.assertEqual(makeReturner2(a=11)()['a'], 11)
|
self.assertEqual(makeReturner2(a=11)()['a'], 11)
|
||||||
|
|
||||||
def makeAddPair((a, b)):
|
with _check_py3k_warnings(("tuple parameter unpacking has been removed",
|
||||||
def addPair((c, d)):
|
SyntaxWarning)):
|
||||||
return (a + c, b + d)
|
exec """\
|
||||||
return addPair
|
def makeAddPair((a, b)):
|
||||||
|
def addPair((c, d)):
|
||||||
|
return (a + c, b + d)
|
||||||
|
return addPair
|
||||||
|
""" in locals()
|
||||||
self.assertEqual(makeAddPair((1, 2))((100, 200)), (101,202))
|
self.assertEqual(makeAddPair((1, 2))((100, 200)), (101,202))
|
||||||
|
|
||||||
def testScopeOfGlobalStmt(self):
|
def testScopeOfGlobalStmt(self):
|
||||||
|
@ -482,7 +483,7 @@ self.assert_(X.passed)
|
||||||
return g
|
return g
|
||||||
|
|
||||||
d = f(2)(4)
|
d = f(2)(4)
|
||||||
self.assert_(d.has_key('h'))
|
self.assertTrue('h' in d)
|
||||||
del d['h']
|
del d['h']
|
||||||
self.assertEqual(d, {'x': 2, 'y': 7, 'w': 6})
|
self.assertEqual(d, {'x': 2, 'y': 7, 'w': 6})
|
||||||
|
|
||||||
|
@ -659,7 +660,9 @@ result2 = h()
|
||||||
|
|
||||||
|
|
||||||
def test_main():
|
def test_main():
|
||||||
run_unittest(ScopeTests)
|
with check_warnings(("import \* only allowed at module level",
|
||||||
|
SyntaxWarning)):
|
||||||
|
run_unittest(ScopeTests)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
test_main()
|
test_main()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue