From: Neil Schemenauer Date: Sat, 7 Feb 2009 18:35:16 +0000 (+0000) Subject: Add test for issue #999042, explict global statement works. X-Git-Tag: v2.7a1~2085 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f8741eacf56574e6b120289156cbdcfb9f7be9b2;p=python Add test for issue #999042, explict global statement works. --- diff --git a/Lib/test/test_compiler.py b/Lib/test/test_compiler.py index c7ec50fe51..052e07e8ff 100644 --- a/Lib/test/test_compiler.py +++ b/Lib/test/test_compiler.py @@ -165,6 +165,13 @@ class CompilerTest(unittest.TestCase): exec c in dct self.assertEquals(dct.get('result'), 1) + def testGlobal(self): + code = compiler.compile('global x\nx=1', '', 'exec') + d1 = {'__builtins__': {}} + d2 = {} + exec code in d1, d2 + # x should be in the globals dict + self.assertEquals(d1.get('x'), 1) def testPrintFunction(self): c = compiler.compile('from __future__ import print_function\n'