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

Method check_common

Lib/test/test_import/__init__.py:2851–2884  ·  view source on GitHub ↗
(self, loaded)

Source from the content-addressed store, hash-verified

2849 # checks
2850
2851 def check_common(self, loaded):
2852 isolated = False
2853
2854 mod = loaded.module
2855 if not mod:
2856 # It came from a subinterpreter.
2857 isolated = True
2858 mod = loaded.snapshot.module
2859 # mod.__name__ might not match, but the spec will.
2860 self.assertEqual(mod.__spec__.name, loaded.name)
2861 self.assertEqual(mod.__file__, self.FILE)
2862 self.assertEqual(mod.__spec__.origin, self.ORIGIN)
2863 if not isolated:
2864 self.assertIsSubclass(mod.error, Exception)
2865 self.assertEqual(mod.int_const, 1969)
2866 self.assertEqual(mod.str_const, 'something different')
2867 self.assertIsInstance(mod._module_initialized, float)
2868 self.assertGreater(mod._module_initialized, 0)
2869
2870 snap = loaded.snapshot
2871 self.assertEqual(snap.summed, 3)
2872 if snap.state_initialized is not None:
2873 self.assertIsInstance(snap.state_initialized, float)
2874 self.assertGreater(snap.state_initialized, 0)
2875 if isolated:
2876 # The "looked up" module is interpreter-specific
2877 # (interp->imports.modules_by_index was set for the module).
2878 self.assertEqual(snap.lookedup_id, snap.id)
2879 self.assertEqual(snap.cached_id, snap.id)
2880 with self.assertRaises(AttributeError):
2881 snap.spam
2882 else:
2883 self.assertIs(snap.lookedup, mod)
2884 self.assertIs(snap.cached, mod)
2885
2886 def check_direct(self, loaded):
2887 # The module has its own PyModuleDef, with a matching name.

Calls 6

assertIsSubclassMethod · 0.80
assertIsInstanceMethod · 0.80
assertGreaterMethod · 0.80
assertEqualMethod · 0.45
assertRaisesMethod · 0.45
assertIsMethod · 0.45