[Python-checkins] r83635 - python/branches/release26-maint/Lib/test/test_scope.py

ezio.melotti python-checkins at python.org
Tue Aug 3 08:37:50 CEST 2010


Author: ezio.melotti
Date: Tue Aug  3 08:37:50 2010
New Revision: 83635

Log:
Fix deprecation warnings in test_scope.py

Modified:
   python/branches/release26-maint/Lib/test/test_scope.py

Modified: python/branches/release26-maint/Lib/test/test_scope.py
==============================================================================
--- python/branches/release26-maint/Lib/test/test_scope.py	(original)
+++ python/branches/release26-maint/Lib/test/test_scope.py	Tue Aug  3 08:37:50 2010
@@ -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):
 
@@ -332,11 +330,14 @@
 
         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):
@@ -482,7 +483,7 @@
             return g
 
         d = f(2)(4)
-        self.assert_(d.has_key('h'))
+        self.assertTrue('h' in d)
         del d['h']
         self.assertEqual(d, {'x': 2, 'y': 7, 'w': 6})
 
@@ -659,7 +660,9 @@
 
 
 def test_main():
-    run_unittest(ScopeTests)
+    with check_warnings(("import \* only allowed at module level",
+                         SyntaxWarning)):
+        run_unittest(ScopeTests)
 
 if __name__ == '__main__':
     test_main()


More information about the Python-checkins mailing list