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

Method test_binary_modes

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

Source from the content-addressed store, hash-verified

1093 return bz2.open(*args, **kwargs)
1094
1095 def test_binary_modes(self):
1096 for mode in ("wb", "xb"):
1097 if mode == "xb":
1098 unlink(self.filename)
1099 with self.open(self.filename, mode) as f:
1100 f.write(self.TEXT)
1101 with open(self.filename, "rb") as f:
1102 file_data = ext_decompress(f.read())
1103 self.assertEqual(file_data, self.TEXT)
1104 with self.open(self.filename, "rb") as f:
1105 self.assertEqual(f.read(), self.TEXT)
1106 with self.open(self.filename, "ab") as f:
1107 f.write(self.TEXT)
1108 with open(self.filename, "rb") as f:
1109 file_data = ext_decompress(f.read())
1110 self.assertEqual(file_data, self.TEXT * 2)
1111
1112 def test_implicit_binary_modes(self):
1113 # Test implicit binary modes (no "b" or "t" in mode string).

Callers

nothing calls this directly

Calls 7

openMethod · 0.95
unlinkFunction · 0.90
ext_decompressFunction · 0.85
openFunction · 0.50
writeMethod · 0.45
readMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected