[pypy-svn] r50273 - in pypy/dist/pypy/module/zipimport: . test
exarkun at codespeak.net
exarkun at codespeak.net
Wed Jan 2 22:52:28 CET 2008
Author: exarkun
Date: Wed Jan 2 22:52:27 2008
New Revision: 50273
Modified:
pypy/dist/pypy/module/zipimport/interp_zipimport.py
pypy/dist/pypy/module/zipimport/test/test_zipimport.py
Log:
Change zipimport.zipimporter.archive to refer to the zipfile, rather than whatever string was passed to __init__
Modified: pypy/dist/pypy/module/zipimport/interp_zipimport.py
==============================================================================
--- pypy/dist/pypy/module/zipimport/interp_zipimport.py (original)
+++ pypy/dist/pypy/module/zipimport/interp_zipimport.py Wed Jan 2 22:52:27 2008
@@ -184,7 +184,9 @@
is_package.unwrap_spec = ['self', ObjSpace, str]
def getarchive(space, self):
- return space.wrap(self.name)
+ space = self.space
+ return space.getattr(self.w_dir, space.wrap('filename'))
+
def descr_new_zipimporter(space, w_type, name):
w_zip_cache = space.getattr(space.getbuiltinmodule('zipimport'),
Modified: pypy/dist/pypy/module/zipimport/test/test_zipimport.py
==============================================================================
--- pypy/dist/pypy/module/zipimport/test/test_zipimport.py (original)
+++ pypy/dist/pypy/module/zipimport/test/test_zipimport.py Wed Jan 2 22:52:27 2008
@@ -214,5 +214,22 @@
assert z.get_source('xx') == "5"
assert z.archive == self.zipfile
+ def test_archive(self):
+ """
+ The archive attribute of zipimport.zipimporter gives the path to the
+ zipfile itself.
+ """
+ import os
+ import zipimport
+ self.writefile(
+ self, os.sep.join(("directory", "package", "__init__.py")), "")
+ importer = zipimport.zipimporter(self.zipfile + "/directory")
+ # Grab this so if the assertion fails, py.test will display its
+ # value. Not sure why it doesn't the assertion uses import.archive
+ # directly. -exarkun
+ archive = importer.archive
+ assert archive == self.zipfile
+
+
class AppTestZipimportDeflated(AppTestZipimport):
compression = ZIP_DEFLATED
More information about the Pypy-commit
mailing list