Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(8)

Side by Side Diff: Lib/test/test_bz2.py

Issue 16510: Using appropriate checks in tests
Patch Set: Created 6 years, 6 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Lib/test/test_bytes.py ('k') | Lib/test/test_capi.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python3 1 #!/usr/bin/env python3
2 from test import support 2 from test import support
3 from test.support import bigmemtest, _4G 3 from test.support import bigmemtest, _4G
4 4
5 import unittest 5 import unittest
6 from io import BytesIO 6 from io import BytesIO
7 import os 7 import os
8 import random 8 import random
9 import subprocess 9 import subprocess
10 import sys 10 import sys
(...skipping 641 matching lines...) Expand 10 before | Expand all | Expand 10 after
652 @bigmemtest(size=_4G + 100, memuse=3) 652 @bigmemtest(size=_4G + 100, memuse=3)
653 def testDecompress4G(self, size): 653 def testDecompress4G(self, size):
654 # "Test BZ2Decompressor.decompress() with >4GiB input" 654 # "Test BZ2Decompressor.decompress() with >4GiB input"
655 blocksize = 10 * 1024 * 1024 655 blocksize = 10 * 1024 * 1024
656 block = random.getrandbits(blocksize * 8).to_bytes(blocksize, 'little') 656 block = random.getrandbits(blocksize * 8).to_bytes(blocksize, 'little')
657 try: 657 try:
658 data = block * (size // blocksize + 1) 658 data = block * (size // blocksize + 1)
659 compressed = bz2.compress(data) 659 compressed = bz2.compress(data)
660 bz2d = BZ2Decompressor() 660 bz2d = BZ2Decompressor()
661 decompressed = bz2d.decompress(compressed) 661 decompressed = bz2d.decompress(compressed)
662 self.assertTrue(decompressed == data) 662 self.assertEqual(decompressed, data)
663 finally: 663 finally:
664 data = None 664 data = None
665 compressed = None 665 compressed = None
666 decompressed = None 666 decompressed = None
667 667
668 668
669 class CompressDecompressTest(BaseTest): 669 class CompressDecompressTest(BaseTest):
670 def testCompress(self): 670 def testCompress(self):
671 data = bz2.compress(self.TEXT) 671 data = bz2.compress(self.TEXT)
672 self.assertEqual(self.decompress(data), self.TEXT) 672 self.assertEqual(self.decompress(data), self.TEXT)
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
800 BZ2FileTest, 800 BZ2FileTest,
801 BZ2CompressorTest, 801 BZ2CompressorTest,
802 BZ2DecompressorTest, 802 BZ2DecompressorTest,
803 CompressDecompressTest, 803 CompressDecompressTest,
804 OpenTest, 804 OpenTest,
805 ) 805 )
806 support.reap_children() 806 support.reap_children()
807 807
808 if __name__ == '__main__': 808 if __name__ == '__main__':
809 test_main() 809 test_main()
OLDNEW
« no previous file with comments | « Lib/test/test_bytes.py ('k') | Lib/test/test_capi.py » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+