Left: | ||
Right: |
OLD | NEW |
---|---|
1 # We can test part of the module without zlib. | 1 # We can test part of the module without zlib. |
2 try: | 2 try: |
3 import zlib | 3 import zlib |
4 except ImportError: | 4 except ImportError: |
5 zlib = None | 5 zlib = None |
6 | 6 |
7 import io | 7 import io |
8 import os | 8 import os |
9 import imp | |
9 import time | 10 import time |
10 import shutil | 11 import shutil |
11 import struct | 12 import struct |
12 import zipfile | 13 import zipfile |
13 import unittest | 14 import unittest |
14 | 15 |
15 | 16 |
16 from tempfile import TemporaryFile | 17 from tempfile import TemporaryFile |
17 from random import randint, random | 18 from random import randint, random |
18 from unittest import skipUnless | 19 from unittest import skipUnless |
(...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
580 zipfile.ZIP64_LIMIT = self._limit | 581 zipfile.ZIP64_LIMIT = self._limit |
581 unlink(TESTFN) | 582 unlink(TESTFN) |
582 unlink(TESTFN2) | 583 unlink(TESTFN2) |
583 | 584 |
584 | 585 |
585 class PyZipFileTests(unittest.TestCase): | 586 class PyZipFileTests(unittest.TestCase): |
586 def test_write_pyfile(self): | 587 def test_write_pyfile(self): |
587 with zipfile.PyZipFile(TemporaryFile(), "w") as zipfp: | 588 with zipfile.PyZipFile(TemporaryFile(), "w") as zipfp: |
588 fn = __file__ | 589 fn = __file__ |
589 if fn.endswith('.pyc') or fn.endswith('.pyo'): | 590 if fn.endswith('.pyc') or fn.endswith('.pyo'): |
590 fn = fn[:-1] | 591 if '__pycache__' in fn: |
Georg
2010/04/10 19:07:56
Probably too nitpicky, but this could pick up an u
barry
2010/04/12 21:59:05
True. Probably doesn't matter for the tests. I d
| |
592 fn = imp.source_from_cache(fn) | |
593 else: | |
594 fn = fn[:-1] | |
591 | 595 |
592 zipfp.writepy(fn) | 596 zipfp.writepy(fn) |
593 | 597 |
594 bn = os.path.basename(fn) | 598 bn = os.path.basename(fn) |
595 self.assertNotIn(bn, zipfp.namelist()) | 599 self.assertNotIn(bn, zipfp.namelist()) |
596 self.assertTrue(bn + 'o' in zipfp.namelist() or | 600 self.assertTrue(bn + 'o' in zipfp.namelist() or |
597 bn + 'c' in zipfp.namelist()) | 601 bn + 'c' in zipfp.namelist()) |
598 | 602 |
599 with zipfile.PyZipFile(TemporaryFile(), "w") as zipfp: | 603 with zipfile.PyZipFile(TemporaryFile(), "w") as zipfp: |
600 fn = __file__ | 604 fn = __file__ |
(...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1239 | 1243 |
1240 | 1244 |
1241 def test_main(): | 1245 def test_main(): |
1242 run_unittest(TestsWithSourceFile, TestZip64InSmallFiles, OtherTests, | 1246 run_unittest(TestsWithSourceFile, TestZip64InSmallFiles, OtherTests, |
1243 PyZipFileTests, DecryptionTests, TestsWithMultipleOpens, | 1247 PyZipFileTests, DecryptionTests, TestsWithMultipleOpens, |
1244 TestWithDirectory, UniversalNewlineTests, | 1248 TestWithDirectory, UniversalNewlineTests, |
1245 TestsWithRandomBinaryFiles) | 1249 TestsWithRandomBinaryFiles) |
1246 | 1250 |
1247 if __name__ == "__main__": | 1251 if __name__ == "__main__": |
1248 test_main() | 1252 test_main() |
OLD | NEW |