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

Method testBadMagic2

Lib/test/test_zipimport.py:282–292  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

280 self.doTest(".py", files, TESTMOD)
281
282 def testBadMagic2(self):
283 # make pyc magic word invalid, causing an ImportError
284 badmagic_pyc = bytearray(test_pyc)
285 badmagic_pyc[0] ^= 0x04 # flip an arbitrary bit
286 files = {TESTMOD + pyc_ext: badmagic_pyc}
287 try:
288 self.doTest(".py", files, TESTMOD)
289 self.fail("This should not be reached")
290 except zipimport.ZipImportError as exc:
291 self.assertIsInstance(exc.__cause__, ImportError)
292 self.assertIn("magic number", exc.__cause__.msg)
293
294 def testBadMTime(self):
295 badtime_pyc = bytearray(test_pyc)

Callers

nothing calls this directly

Calls 4

doTestMethod · 0.95
assertIsInstanceMethod · 0.80
assertInMethod · 0.80
failMethod · 0.45

Tested by

no test coverage detected