MCPcopy Index your code
hub / github.com/python/cpython / test_exec_frozendict

Method test_exec_frozendict

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

Source from the content-addressed store, hash-verified

893 self.assertEqual((g, l), ({'a': 1}, {'b': 2}))
894
895 def test_exec_frozendict(self):
896 ns = frozendict(x=1, data=[], __builtins__=__builtins__)
897 exec("data.append(x)", ns, ns)
898 self.assertEqual(ns['data'], [1])
899
900 ns = frozendict(__builtins__=__builtins__)
901 errmsg = "'frozendict' object does not support item assignment"
902 with self.assertRaisesRegex(TypeError, errmsg):
903 exec("x = 1", ns, ns)
904
905 ns = frozendict()
906 errmsg = "cannot assign __builtins__ to frozendict globals"
907 with self.assertRaisesRegex(TypeError, errmsg):
908 exec("", ns, ns)
909
910 def test_exec_kwargs(self):
911 g = {}

Callers

nothing calls this directly

Calls 3

frozendictClass · 0.85
assertRaisesRegexMethod · 0.80
assertEqualMethod · 0.45

Tested by

no test coverage detected