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

Method test_text_modes

Lib/test/test_zstd.py:2525–2547  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

2523 self.assertEqual(file_data, DECOMPRESSED_100_PLUS_32KB * 2)
2524
2525 def test_text_modes(self):
2526 # empty input
2527 with self.assertRaises(EOFError):
2528 with open(io.BytesIO(b''), "rt", encoding="utf-8", newline='\n') as reader:
2529 for _ in reader:
2530 pass
2531
2532 # read
2533 uncompressed = THIS_FILE_STR.replace(os.linesep, "\n")
2534 with open(io.BytesIO(COMPRESSED_THIS_FILE), "rt", encoding="utf-8") as f:
2535 self.assertEqual(f.read(), uncompressed)
2536
2537 with io.BytesIO() as bio:
2538 # write
2539 with open(bio, "wt", encoding="utf-8") as f:
2540 f.write(uncompressed)
2541 file_data = decompress(bio.getvalue()).decode("utf-8")
2542 self.assertEqual(file_data.replace(os.linesep, "\n"), uncompressed)
2543 # append
2544 with open(bio, "at", encoding="utf-8") as f:
2545 f.write(uncompressed)
2546 file_data = decompress(bio.getvalue()).decode("utf-8")
2547 self.assertEqual(file_data.replace(os.linesep, "\n"), uncompressed * 2)
2548
2549 def test_bad_params(self):
2550 with tempfile.NamedTemporaryFile(delete=False) as tmp_f:

Callers

nothing calls this directly

Calls 9

openFunction · 0.90
decompressFunction · 0.90
assertRaisesMethod · 0.45
replaceMethod · 0.45
assertEqualMethod · 0.45
readMethod · 0.45
writeMethod · 0.45
decodeMethod · 0.45
getvalueMethod · 0.45

Tested by

no test coverage detected