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

Method testContextProtocol

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

Source from the content-addressed store, hash-verified

486 self.assertEqual(xlines, [b'Test'])
487
488 def testContextProtocol(self):
489 with BZ2File(self.filename, "wb") as f:
490 f.write(b"xxx")
491 f = BZ2File(self.filename, "rb")
492 f.close()
493 try:
494 with f:
495 pass
496 except ValueError:
497 pass
498 else:
499 self.fail("__enter__ on a closed file didn't raise an exception")
500 try:
501 with BZ2File(self.filename, "wb") as f:
502 1/0
503 except ZeroDivisionError:
504 pass
505 else:
506 self.fail("1/0 didn't raise an exception")
507
508 @threading_helper.requires_working_threading()
509 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