Ignore:
Timestamp:
Mar 19, 2014, 11:31:01 PM (11 years ago)
Author:
dmik
Message:

python: Merge vendor 2.7.6 to trunk.

Location:
python/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • python/trunk

  • python/trunk/Lib/test/test_scope.py

    r2 r391  
    11import 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>")
     2from test.test_support import check_syntax_error, check_py3k_warnings, \
     3                              check_warnings, run_unittest
     4
    75
    86class ScopeTests(unittest.TestCase):
     
    290288            y = 1
    291289
    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)
    305292
    306293        # test for bug #1501934: incorrect LOAD/STORE_GLOBAL generation
     
    333320        self.assertEqual(makeReturner2(a=11)()['a'], 11)
    334321
    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 """\
     325def makeAddPair((a, b)):
     326    def addPair((c, d)):
     327        return (a + c, b + d)
     328    return addPair
     329""" in locals()
    340330        self.assertEqual(makeAddPair((1, 2))((100, 200)), (101,202))
    341331
     
    468458    passed = looked_up_by_load_name
    469459
    470 self.assert_(X.passed)
     460self.assertTrue(X.passed)
    471461"""
    472462
     
    483473
    484474        d = f(2)(4)
    485         self.assert_(d.has_key('h'))
     475        self.assertIn('h', d)
    486476        del d['h']
    487477        self.assertEqual(d, {'x': 2, 'y': 7, 'w': 6})
     
    517507
    518508        varnames = f(1).z
    519         self.assert_("x" not in varnames)
    520         self.assert_("y" in varnames)
     509        self.assertNotIn("x", varnames)
     510        self.assertIn("y", varnames)
    521511
    522512    def testLocalsClass_WithTrace(self):
     
    534524                    return x
    535525
    536             self.assertEquals(x, 12) # Used to raise UnboundLocalError
     526            self.assertEqual(x, 12) # Used to raise UnboundLocalError
    537527        finally:
    538528            sys.settrace(None)
     
    658648        self.assertEqual(9, global_ns["result9"])
    659649
     650    def testTopIsNotSignificant(self):
     651        # See #9997.
     652        def top(a):
     653            pass
     654        def b():
     655            global a
     656
    660657
    661658def test_main():
    662     run_unittest(ScopeTests)
     659    with check_warnings(("import \* only allowed at module level",
     660                         SyntaxWarning)):
     661        run_unittest(ScopeTests)
    663662
    664663if __name__ == '__main__':
Note: See TracChangeset for help on using the changeset viewer.