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

Method test_assign_init_code

Lib/test/test_opcache.py:528–547  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

526 @requires_jit_disabled
527 @requires_specialization
528 def test_assign_init_code(self):
529 class MyClass:
530 def __init__(self):
531 pass
532
533 def instantiate():
534 return MyClass()
535
536 # Trigger specialization
537 for _ in range(_testinternalcapi.SPECIALIZATION_THRESHOLD):
538 instantiate()
539 self.assert_specialized(instantiate, "CALL_ALLOC_AND_ENTER_INIT")
540
541 def count_args(self, *args):
542 self.num_args = len(args)
543
544 # Set MyClass.__init__.__code__ to a code object that uses different
545 # args
546 MyClass.__init__.__code__ = count_args.__code__
547 instantiate()
548
549 @requires_jit_disabled
550 @requires_specialization

Callers

nothing calls this directly

Calls 1

assert_specializedMethod · 0.80

Tested by

no test coverage detected