summaryrefslogtreecommitdiff
path: root/Lib/test/test_scope.py
diff options
context:
space:
mode:
authorFlorent Xicluna <florent.xicluna@gmail.com>2010-03-19 18:34:55 +0000
committerFlorent Xicluna <florent.xicluna@gmail.com>2010-03-19 18:34:55 +0000
commitbc27c6a5aa75a8f52304ecd311fbadef4ec621ce (patch)
tree5634ee9187192196c6e565e491144e2574c436ef /Lib/test/test_scope.py
parent4854c969fb6f42b3d67e14977bc3f0f6f3ec70c9 (diff)
downloadcpython-git-bc27c6a5aa75a8f52304ecd311fbadef4ec621ce.tar.gz
Various tests cleanup: check_warnings/check_py3k_warnings, unittest.assert* and setUp/tearDown.
Diffstat (limited to 'Lib/test/test_scope.py')
-rw-r--r--Lib/test/test_scope.py25
1 files changed, 14 insertions, 11 deletions
diff --git a/Lib/test/test_scope.py b/Lib/test/test_scope.py
index 76ab192338..b1549ef43e 100644
--- a/Lib/test/test_scope.py
+++ b/Lib/test/test_scope.py
@@ -1,9 +1,7 @@
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):
@@ -321,11 +319,14 @@ else:
self.assertEqual(makeReturner2(a=11)()['a'], 11)
- def makeAddPair((a, b)):
- def addPair((c, d)):
- return (a + c, b + d)
- return addPair
-
+ with check_py3k_warnings(("tuple parameter unpacking has been removed",
+ SyntaxWarning)):
+ exec """\
+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))
def testScopeOfGlobalStmt(self):
@@ -471,7 +472,7 @@ self.assertTrue(X.passed)
return g
d = f(2)(4)
- self.assertTrue(d.has_key('h'))
+ self.assertIn('h', d)
del d['h']
self.assertEqual(d, {'x': 2, 'y': 7, 'w': 6})
@@ -648,7 +649,9 @@ result2 = h()
def test_main():
- run_unittest(ScopeTests)
+ with check_warnings(("import \* only allowed at module level",
+ SyntaxWarning)):
+ run_unittest(ScopeTests)
if __name__ == '__main__':
test_main()