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

Method check_same_constant

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

Source from the content-addressed store, hash-verified

795 # and have the same type.
796
797 def check_same_constant(const):
798 ns = {}
799 code = "f1, f2 = lambda: %r, lambda: %r" % (const, const)
800 exec(code, ns)
801 f1 = ns['f1']
802 f2 = ns['f2']
803 self.assertIs(f1.__code__.co_consts, f2.__code__.co_consts)
804 self.check_constant(f1, const)
805 self.assertEqual(repr(f1()), repr(const))
806
807 check_same_constant(None)
808 check_same_constant(0.0)

Callers

nothing calls this directly

Calls 6

check_constantMethod · 0.95
reprFunction · 0.85
f1Function · 0.70
execFunction · 0.50
assertIsMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected