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

Method check_same_constant

Lib/test/test_compile.py:786–794  ·  view source on GitHub ↗
(const)

Source from the content-addressed store, hash-verified

784 # and have the same type.
785
786 def check_same_constant(const):
787 ns = {}
788 code = "f1, f2 = lambda: %r, lambda: %r" % (const, const)
789 exec(code, ns)
790 f1 = ns['f1']
791 f2 = ns['f2']
792 self.assertIs(f1.__code__.co_consts, f2.__code__.co_consts)
793 self.check_constant(f1, const)
794 self.assertEqual(repr(f1()), repr(const))
795
796 check_same_constant(None)
797 check_same_constant(0.0)

Callers

nothing calls this directly

Calls 4

check_constantMethod · 0.95
f1Function · 0.85
assertIsMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected