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

Method testContextProtocol

Lib/test/test_bz2.py:478–496  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

476 self.assertEqual(xlines, [b'Test'])
477
478 def testContextProtocol(self):
479 with BZ2File(self.filename, "wb") as f:
480 f.write(b"xxx")
481 f = BZ2File(self.filename, "rb")
482 f.close()
483 try:
484 with f:
485 pass
486 except ValueError:
487 pass
488 else:
489 self.fail("__enter__ on a closed file didn't raise an exception")
490 try:
491 with BZ2File(self.filename, "wb") as f:
492 1/0
493 except ZeroDivisionError:
494 pass
495 else:
496 self.fail("1/0 didn't raise an exception")
497
498 @threading_helper.requires_working_threading()
499 def testThreading(self):

Callers

nothing calls this directly

Calls 4

writeMethod · 0.95
closeMethod · 0.95
BZ2FileClass · 0.90
failMethod · 0.45

Tested by

no test coverage detected