MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_exec

Method test_exec

Lib/test/test_builtin.py:855–877  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

853 self.assertRaises(TypeError, eval, 'dir()', globals(), C())
854
855 def test_exec(self):
856 g = {}
857 exec('z = 1', g)
858 if '__builtins__' in g:
859 del g['__builtins__']
860 self.assertEqual(g, {'z': 1})
861
862 exec('z = 1+1', g)
863 if '__builtins__' in g:
864 del g['__builtins__']
865 self.assertEqual(g, {'z': 2})
866 g = {}
867 l = {}
868
869 with check_warnings():
870 warnings.filterwarnings("ignore", "global statement",
871 module="<string>")
872 exec('global a; a = 1; b = 2', g, l)
873 if '__builtins__' in g:
874 del g['__builtins__']
875 if '__builtins__' in l:
876 del l['__builtins__']
877 self.assertEqual((g, l), ({'a': 1}, {'b': 2}))
878
879 def test_exec_kwargs(self):
880 g = {}

Callers

nothing calls this directly

Calls 3

check_warningsFunction · 0.90
execFunction · 0.50
assertEqualMethod · 0.45

Tested by

no test coverage detected