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

Method assert_func_defs_other_unpickle

Lib/test/test_crossinterp.py:728–750  ·  view source on GitHub ↗
(self, defs, mod, *, fail=False)

Source from the content-addressed store, hash-verified

726 self.assert_not_shareable(defs.TOP_FUNCTIONS)
727
728 def assert_func_defs_other_unpickle(self, defs, mod, *, fail=False):
729 # Unpickle relative to a different module than the original.
730 for func in defs.TOP_FUNCTIONS:
731 assert not hasattr(mod, func.__name__), (getattr(mod, func.__name__),)
732
733 captured = []
734 for func in defs.TOP_FUNCTIONS:
735 with self.subTest(func):
736 setattr(mod, func.__name__, func)
737 xid = self.get_xidata(func)
738 captured.append(
739 (func, xid))
740
741 for func, xid in captured:
742 with self.subTest(func):
743 delattr(mod, func.__name__)
744 if fail:
745 with self.assertRaises(NotShareableError):
746 _testinternalcapi.restore_crossinterp_data(xid)
747 continue
748 got = _testinternalcapi.restore_crossinterp_data(xid)
749 self.assertIsNot(got, func)
750 self.assertNotEqual(got, func)
751
752 def assert_func_defs_not_shareable(self, defs):
753 self.assert_not_shareable(defs.TOP_FUNCTIONS)

Calls 6

get_xidataMethod · 0.80
assertIsNotMethod · 0.80
assertNotEqualMethod · 0.80
subTestMethod · 0.45
appendMethod · 0.45
assertRaisesMethod · 0.45

Tested by

no test coverage detected