Make test_builtin work when executed directly

This commit is contained in:
Brett Cannon 2013-06-15 23:24:11 -04:00
parent 22ba31a3af
commit 2f9f056db1
1 changed files with 4 additions and 1 deletions

View File

@ -584,6 +584,9 @@ class BuiltinTest(unittest.TestCase):
raise frozendict_error("frozendict is readonly") raise frozendict_error("frozendict is readonly")
# read-only builtins # read-only builtins
if isinstance(__builtins__, types.ModuleType):
frozen_builtins = frozendict(__builtins__.__dict__)
else:
frozen_builtins = frozendict(__builtins__) frozen_builtins = frozendict(__builtins__)
code = compile("__builtins__['superglobal']=2; print(superglobal)", "test", "exec") code = compile("__builtins__['superglobal']=2; print(superglobal)", "test", "exec")
self.assertRaises(frozendict_error, self.assertRaises(frozendict_error,