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

Method test_text_modes

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

Source from the content-addressed store, hash-verified

1119 self.assertEqual(file_data, self.TEXT * 2)
1120
1121 def test_text_modes(self):
1122 text = self.TEXT.decode("ascii")
1123 text_native_eol = text.replace("\n", os.linesep)
1124 for mode in ("wt", "xt"):
1125 if mode == "xt":
1126 unlink(self.filename)
1127 with self.open(self.filename, mode, encoding="ascii") as f:
1128 f.write(text)
1129 with open(self.filename, "rb") as f:
1130 file_data = ext_decompress(f.read()).decode("ascii")
1131 self.assertEqual(file_data, text_native_eol)
1132 with self.open(self.filename, "rt", encoding="ascii") as f:
1133 self.assertEqual(f.read(), text)
1134 with self.open(self.filename, "at", encoding="ascii") as f:
1135 f.write(text)
1136 with open(self.filename, "rb") as f:
1137 file_data = ext_decompress(f.read()).decode("ascii")
1138 self.assertEqual(file_data, text_native_eol * 2)
1139
1140 def test_x_mode(self):
1141 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