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

Method test_globals_shadow_builtins

Lib/test/test_dynamic.py:29–37  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

27 pass
28
29 def test_globals_shadow_builtins(self):
30 # Modify globals() to shadow an entry in builtins.
31 def foo():
32 return len([1, 2, 3])
33 self.configure_func(foo)
34
35 self.assertEqual(foo(), 3)
36 with swap_item(globals(), "len", lambda x: 7):
37 self.assertEqual(foo(), 7)
38
39 def test_modify_builtins(self):
40 # Modify the builtins module directly.

Callers

nothing calls this directly

Calls 4

configure_funcMethod · 0.95
swap_itemFunction · 0.90
fooFunction · 0.70
assertEqualMethod · 0.45

Tested by

no test coverage detected