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

Method test_with_open

Lib/test/test_gzip.py:428–447  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

426 self.assertEqual(xflByte, expectedXflByte)
427
428 def test_with_open(self):
429 # GzipFile supports the context management protocol
430 with gzip.GzipFile(self.filename, "wb") as f:
431 f.write(b"xxx")
432 f = gzip.GzipFile(self.filename, "rb")
433 f.close()
434 try:
435 with f:
436 pass
437 except ValueError:
438 pass
439 else:
440 self.fail("__enter__ on a closed file didn't raise an exception")
441 try:
442 with gzip.GzipFile(self.filename, "wb") as f:
443 1/0
444 except ZeroDivisionError:
445 pass
446 else:
447 self.fail("1/0 didn't raise an exception")
448
449 def test_zero_padded_file(self):
450 with gzip.GzipFile(self.filename, "wb") as f:

Callers

nothing calls this directly

Calls 3

writeMethod · 0.95
closeMethod · 0.95
failMethod · 0.45

Tested by

no test coverage detected