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

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

Issue 23670: Modifications to support iOS as a development platform
Patch Set: Created 3 years, 8 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_webbrowser.py ('k') | Lib/unittest/test/test_runner.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 import contextlib 1 import contextlib
2 import io 2 import io
3 import os 3 import os
4 import sys 4 import sys
5 import importlib.util 5 import importlib.util
6 import posixpath 6 import posixpath
7 import time 7 import time
8 import struct 8 import struct
9 import zipfile 9 import zipfile
10 import unittest 10 import unittest
(...skipping 675 matching lines...) Expand 10 before | Expand all | Expand 10 after
686 effective_ids=os.access in os.supports_effective_ids): 686 effective_ids=os.access in os.supports_effective_ids):
687 self.skipTest('requires write access to the installed location') 687 self.skipTest('requires write access to the installed location')
688 filename = os.path.join(path, 'test_zipfile.try') 688 filename = os.path.join(path, 'test_zipfile.try')
689 try: 689 try:
690 fd = os.open(filename, os.O_WRONLY | os.O_CREAT) 690 fd = os.open(filename, os.O_WRONLY | os.O_CREAT)
691 os.close(fd) 691 os.close(fd)
692 except Exception: 692 except Exception:
693 self.skipTest('requires write access to the installed location') 693 self.skipTest('requires write access to the installed location')
694 unlink(filename) 694 unlink(filename)
695 695
696 @unittest.skipIf(sys.dont_write_bytecode, "Test requires ability to write by tecode")
696 def test_write_pyfile(self): 697 def test_write_pyfile(self):
697 self.requiresWriteAccess(os.path.dirname(__file__)) 698 self.requiresWriteAccess(os.path.dirname(__file__))
698 with TemporaryFile() as t, zipfile.PyZipFile(t, "w") as zipfp: 699 with TemporaryFile() as t, zipfile.PyZipFile(t, "w") as zipfp:
699 fn = __file__ 700 fn = __file__
700 if fn.endswith('.pyc'): 701 if fn.endswith('.pyc'):
701 path_split = fn.split(os.sep) 702 path_split = fn.split(os.sep)
702 if os.altsep is not None: 703 if os.altsep is not None:
703 path_split.extend(fn.split(os.altsep)) 704 path_split.extend(fn.split(os.altsep))
704 if '__pycache__' in path_split: 705 if '__pycache__' in path_split:
705 fn = importlib.util.source_from_cache(fn) 706 fn = importlib.util.source_from_cache(fn)
(...skipping 24 matching lines...) Expand all
730 731
731 with TemporaryFile() as t, zipfile.PyZipFile(t, "w") as zipfp: 732 with TemporaryFile() as t, zipfile.PyZipFile(t, "w") as zipfp:
732 zipfp.writepy(packagedir) 733 zipfp.writepy(packagedir)
733 734
734 # Check for a couple of modules at different levels of the 735 # Check for a couple of modules at different levels of the
735 # hierarchy 736 # hierarchy
736 names = zipfp.namelist() 737 names = zipfp.namelist()
737 self.assertCompiledIn('email/__init__.py', names) 738 self.assertCompiledIn('email/__init__.py', names)
738 self.assertCompiledIn('email/mime/text.py', names) 739 self.assertCompiledIn('email/mime/text.py', names)
739 740
741 @unittest.skipIf(sys.dont_write_bytecode, "Test requires ability to write by tecode")
740 def test_write_filtered_python_package(self): 742 def test_write_filtered_python_package(self):
741 import test 743 import test
742 packagedir = os.path.dirname(test.__file__) 744 packagedir = os.path.dirname(test.__file__)
743 self.requiresWriteAccess(packagedir) 745 self.requiresWriteAccess(packagedir)
744 746
745 with TemporaryFile() as t, zipfile.PyZipFile(t, "w") as zipfp: 747 with TemporaryFile() as t, zipfile.PyZipFile(t, "w") as zipfp:
746 748
747 # first make sure that the test folder gives error messages 749 # first make sure that the test folder gives error messages
748 # (on the badsyntax_... files) 750 # (on the badsyntax_... files)
749 with captured_stdout() as reportSIO: 751 with captured_stdout() as reportSIO:
(...skipping 1331 matching lines...) Expand 10 before | Expand all | Expand 10 after
2081 def test_from_dir(self): 2083 def test_from_dir(self):
2082 dirpath = os.path.dirname(os.path.abspath(__file__)) 2084 dirpath = os.path.dirname(os.path.abspath(__file__))
2083 zi = zipfile.ZipInfo.from_file(dirpath, 'stdlib_tests') 2085 zi = zipfile.ZipInfo.from_file(dirpath, 'stdlib_tests')
2084 self.assertEqual(zi.filename, 'stdlib_tests/') 2086 self.assertEqual(zi.filename, 'stdlib_tests/')
2085 self.assertTrue(zi.is_dir()) 2087 self.assertTrue(zi.is_dir())
2086 self.assertEqual(zi.compress_type, zipfile.ZIP_STORED) 2088 self.assertEqual(zi.compress_type, zipfile.ZIP_STORED)
2087 self.assertEqual(zi.file_size, 0) 2089 self.assertEqual(zi.file_size, 0)
2088 2090
2089 if __name__ == "__main__": 2091 if __name__ == "__main__":
2090 unittest.main() 2092 unittest.main()
OLDNEW
« no previous file with comments | « Lib/test/test_webbrowser.py ('k') | Lib/unittest/test/test_runner.py » ('j') | no next file with comments »

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