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

Method test_text_modes

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

Source from the content-addressed store, hash-verified

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