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

Method test_with_open

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

Source from the content-addressed store, hash-verified

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