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

Method test_implicit_binary_modes

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

Source from the content-addressed store, hash-verified

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).
1114 for mode in ("w", "x"):
1115 if mode == "x":
1116 unlink(self.filename)
1117 with self.open(self.filename, mode) as f:
1118 f.write(self.TEXT)
1119 with open(self.filename, "rb") as f:
1120 file_data = ext_decompress(f.read())
1121 self.assertEqual(file_data, self.TEXT)
1122 with self.open(self.filename, "r") as f:
1123 self.assertEqual(f.read(), self.TEXT)
1124 with self.open(self.filename, "a") as f:
1125 f.write(self.TEXT)
1126 with open(self.filename, "rb") as f:
1127 file_data = ext_decompress(f.read())
1128 self.assertEqual(file_data, self.TEXT * 2)
1129
1130 def test_text_modes(self):
1131 text = self.TEXT.decode("ascii")

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