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

Method test_text_modes

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

Source from the content-addressed store, hash-verified

1128 self.assertEqual(file_data, self.TEXT * 2)
1129
1130 def test_text_modes(self):
1131 text = self.TEXT.decode("ascii")
1132 text_native_eol = text.replace("\n", os.linesep)
1133 for mode in ("wt", "xt"):
1134 if mode == "xt":
1135 unlink(self.filename)
1136 with self.open(self.filename, mode, encoding="ascii") as f:
1137 f.write(text)
1138 with open(self.filename, "rb") as f:
1139 file_data = ext_decompress(f.read()).decode("ascii")
1140 self.assertEqual(file_data, text_native_eol)
1141 with self.open(self.filename, "rt", encoding="ascii") as f:
1142 self.assertEqual(f.read(), text)
1143 with self.open(self.filename, "at", encoding="ascii") as f:
1144 f.write(text)
1145 with open(self.filename, "rb") as f:
1146 file_data = ext_decompress(f.read()).decode("ascii")
1147 self.assertEqual(file_data, text_native_eol * 2)
1148
1149 def test_x_mode(self):
1150 for mode in ("x", "xb", "xt"):

Callers

nothing calls this directly

Calls 9

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

Tested by

no test coverage detected