[Python-checkins] python/dist/src/Lib/test test_zipimport.py,1.9,1.10
theller@users.sourceforge.net
theller@users.sourceforge.net
Tue, 22 Jul 2003 11:10:04 -0700
Update of /cvsroot/python/python/dist/src/Lib/test
In directory sc8-pr-cvs1:/tmp/cvs-serv9380
Modified Files:
test_zipimport.py
Log Message:
Change the zipimport implementation to accept files containing
arbitrary bytes before the actual zip compatible archive. Zipfiles
containing comments at the end of the file are still not supported.
Add a testcase to test_zipimport, and update NEWS.
This closes sf #775637 and sf #669036.
Index: test_zipimport.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_zipimport.py,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** test_zipimport.py 10 May 2003 07:36:55 -0000 1.9
--- test_zipimport.py 22 Jul 2003 18:10:02 -0000 1.10
***************
*** 50,54 ****
ImportHooksBaseTestCase.setUp(self)
! def doTest(self, expected_ext, files, *modules):
z = ZipFile(TEMP_ZIP, "w")
try:
--- 50,54 ----
ImportHooksBaseTestCase.setUp(self)
! def doTest(self, expected_ext, files, *modules, **kw):
z = ZipFile(TEMP_ZIP, "w")
try:
***************
*** 58,61 ****
--- 58,74 ----
z.writestr(zinfo, data)
z.close()
+
+ stuff = kw.get("stuff", None)
+ if stuff is not None:
+ # Prepend 'stuff' to the start of the zipfile
+ f = open(TEMP_ZIP, "rb")
+ data = f.read()
+ f.close()
+
+ f = open(TEMP_ZIP, "wb")
+ f.write(stuff)
+ f.write(data)
+ f.close()
+
sys.path.insert(0, TEMP_ZIP)
***************
*** 182,185 ****
--- 195,204 ----
self.doTest(pyc_ext, files, TESTMOD)
+ def testImport_WithStuff(self):
+ # try importing from a zipfile which contains additional
+ # stuff at the beginning of the file
+ files = {TESTMOD + ".py": (NOW, test_src)}
+ self.doTest(".py", files, TESTMOD,
+ stuff="Some Stuff"*31)
class CompressedZipImportTestCase(UncompressedZipImportTestCase):