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

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

Issue 16510: Using appropriate checks in tests
Patch Set: Created 7 years, 4 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 634 matching lines...) Expand 10 before | Expand all | Expand 10 after
645 @bigmemtest(size=_4G + 100, memuse=3) 645 @bigmemtest(size=_4G + 100, memuse=3)
646 def testDecompress4G(self, size): 646 def testDecompress4G(self, size):
647 # "Test BZ2Decompressor.decompress() with >4GiB input" 647 # "Test BZ2Decompressor.decompress() with >4GiB input"
648 blocksize = 10 * 1024 * 1024 648 blocksize = 10 * 1024 * 1024
649 block = random.getrandbits(blocksize * 8).to_bytes(blocksize, 'little') 649 block = random.getrandbits(blocksize * 8).to_bytes(blocksize, 'little')
650 try: 650 try:
651 data = block * (size // blocksize + 1) 651 data = block * (size // blocksize + 1)
652 compressed = bz2.compress(data) 652 compressed = bz2.compress(data)
653 bz2d = BZ2Decompressor() 653 bz2d = BZ2Decompressor()
654 decompressed = bz2d.decompress(compressed) 654 decompressed = bz2d.decompress(compressed)
655 self.assertTrue(decompressed == data) 655 self.assertEqual(decompressed, data)
656 finally: 656 finally:
657 data = None 657 data = None
658 compressed = None 658 compressed = None
659 decompressed = None 659 decompressed = None
660 660
661 661
662 class CompressDecompressTest(BaseTest): 662 class CompressDecompressTest(BaseTest):
663 def testCompress(self): 663 def testCompress(self):
664 data = bz2.compress(self.TEXT) 664 data = bz2.compress(self.TEXT)
665 self.assertEqual(self.decompress(data), self.TEXT) 665 self.assertEqual(self.decompress(data), self.TEXT)
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
785 BZ2FileTest, 785 BZ2FileTest,
786 BZ2CompressorTest, 786 BZ2CompressorTest,
787 BZ2DecompressorTest, 787 BZ2DecompressorTest,
788 CompressDecompressTest, 788 CompressDecompressTest,
789 OpenTest, 789 OpenTest,
790 ) 790 )
791 support.reap_children() 791 support.reap_children()
792 792
793 if __name__ == '__main__': 793 if __name__ == '__main__':
794 test_main() 794 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+