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

Method test_modify_builtins

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

Source from the content-addressed store, hash-verified

37 self.assertEqual(foo(), 7)
38
39 def test_modify_builtins(self):
40 # Modify the builtins module directly.
41 def foo():
42 return len([1, 2, 3])
43 self.configure_func(foo)
44
45 self.assertEqual(foo(), 3)
46 with swap_attr(builtins, "len", lambda x: 7):
47 self.assertEqual(foo(), 7)
48
49 def test_modify_builtins_while_generator_active(self):
50 # Modify the builtins out from under a live generator.

Callers

nothing calls this directly

Calls 4

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

Tested by

no test coverage detected