Changeset 391 for python/trunk/Lib/test/test_scope.py
- Timestamp:
- Mar 19, 2014, 11:31:01 PM (11 years ago)
- Location:
- python/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
python/trunk
-
Property svn:mergeinfo
set to
/python/vendor/Python-2.7.6 merged eligible /python/vendor/current merged eligible
-
Property svn:mergeinfo
set to
-
python/trunk/Lib/test/test_scope.py
r2 r391 1 1 import unittest 2 from test.test_support import check_syntax_error, run_unittest 3 4 import warnings 5 warnings.filterwarnings("ignore", r"import \*", SyntaxWarning, "<test string>") 6 warnings.filterwarnings("ignore", r"import \*", SyntaxWarning, "<string>") 2 from test.test_support import check_syntax_error, check_py3k_warnings, \ 3 check_warnings, run_unittest 4 7 5 8 6 class ScopeTests(unittest.TestCase): … … 290 288 y = 1 291 289 292 try: 293 errorInOuter() 294 except UnboundLocalError: 295 pass 296 else: 297 self.fail() 298 299 try: 300 errorInInner() 301 except NameError: 302 pass 303 else: 304 self.fail() 290 self.assertRaises(UnboundLocalError, errorInOuter) 291 self.assertRaises(NameError, errorInInner) 305 292 306 293 # test for bug #1501934: incorrect LOAD/STORE_GLOBAL generation … … 333 320 self.assertEqual(makeReturner2(a=11)()['a'], 11) 334 321 335 def makeAddPair((a, b)): 336 def addPair((c, d)): 337 return (a + c, b + d) 338 return addPair 339 322 with check_py3k_warnings(("tuple parameter unpacking has been removed", 323 SyntaxWarning)): 324 exec """\ 325 def makeAddPair((a, b)): 326 def addPair((c, d)): 327 return (a + c, b + d) 328 return addPair 329 """ in locals() 340 330 self.assertEqual(makeAddPair((1, 2))((100, 200)), (101,202)) 341 331 … … 468 458 passed = looked_up_by_load_name 469 459 470 self.assert _(X.passed)460 self.assertTrue(X.passed) 471 461 """ 472 462 … … 483 473 484 474 d = f(2)(4) 485 self.assert _(d.has_key('h'))475 self.assertIn('h', d) 486 476 del d['h'] 487 477 self.assertEqual(d, {'x': 2, 'y': 7, 'w': 6}) … … 517 507 518 508 varnames = f(1).z 519 self.assert _("x" not invarnames)520 self.assert _("y" invarnames)509 self.assertNotIn("x", varnames) 510 self.assertIn("y", varnames) 521 511 522 512 def testLocalsClass_WithTrace(self): … … 534 524 return x 535 525 536 self.assertEqual s(x, 12) # Used to raise UnboundLocalError526 self.assertEqual(x, 12) # Used to raise UnboundLocalError 537 527 finally: 538 528 sys.settrace(None) … … 658 648 self.assertEqual(9, global_ns["result9"]) 659 649 650 def testTopIsNotSignificant(self): 651 # See #9997. 652 def top(a): 653 pass 654 def b(): 655 global a 656 660 657 661 658 def test_main(): 662 run_unittest(ScopeTests) 659 with check_warnings(("import \* only allowed at module level", 660 SyntaxWarning)): 661 run_unittest(ScopeTests) 663 662 664 663 if __name__ == '__main__':
Note:
See TracChangeset
for help on using the changeset viewer.