[pypy-commit] pypy py3k: Make most zipimport tests pass with -A
amauryfa
noreply at buildbot.pypy.org
Tue Nov 20 23:16:43 CET 2012
Author: Amaury Forgeot d'Arc <amauryfa at gmail.com>
Branch: py3k
Changeset: r59020:a50947880a7a
Date: 2012-11-20 23:14 +0100
http://bitbucket.org/pypy/pypy/changeset/a50947880a7a/
Log: Make most zipimport tests pass with -A
diff --git a/pypy/module/zipimport/test/test_undocumented.py b/pypy/module/zipimport/test/test_undocumented.py
--- a/pypy/module/zipimport/test/test_undocumented.py
+++ b/pypy/module/zipimport/test/test_undocumented.py
@@ -130,7 +130,7 @@
try:
importer = zipimport.zipimporter(os.path.join(zip_path, '_pkg'))
assert zip_path in zipimport._zip_directory_cache
- file_set = set(zipimport._zip_directory_cache[zip_path].iterkeys())
+ file_set = set(zipimport._zip_directory_cache[zip_path].keys())
compare_set = set(path.replace(os.path.sep, '/') + '.py'
for path in self.created_paths)
assert file_set == compare_set
diff --git a/pypy/tool/pytest/apptest.py b/pypy/tool/pytest/apptest.py
--- a/pypy/tool/pytest/apptest.py
+++ b/pypy/tool/pytest/apptest.py
@@ -74,11 +74,17 @@
elif isinstance(value, types.ModuleType):
name = value.__name__
defs.append("import %s; self.%s = %s\n" % (name, symbol, name))
- elif isinstance(value, (int, str)):
+ elif isinstance(value, str):
+ # python2 string -> Bytes string
+ defs.append("self.%s = b%r\n" % (symbol, value))
+ elif isinstance(value, unicode):
+ # python2 unicode -> python3 string
+ defs.append("self.%s = %s\n" % (symbol, repr(value)[1:]))
+ elif isinstance(value, (int, float, list)):
defs.append("self.%s = %r\n" % (symbol, value))
- source = py.code.Source(target_)[1:].deindent()
+ source = py.code.Source(target_)[1:]
pyfile = udir.join('src.py')
- source = helpers + '\n'.join(defs) + str(source)
+ source = helpers + '\n'.join(defs) + 'if 1:\n' + str(source)
with pyfile.open('w') as f:
f.write(source)
res, stdout, stderr = runsubprocess.run_subprocess(
diff --git a/pypy/tool/pytest/objspace.py b/pypy/tool/pytest/objspace.py
--- a/pypy/tool/pytest/objspace.py
+++ b/pypy/tool/pytest/objspace.py
@@ -83,6 +83,11 @@
return (src, args)
def wrap(self, obj):
+ if isinstance(obj, str):
+ return obj.decode('utf-8')
+ return obj
+
+ def wrapbytes(self, obj):
return obj
def unpackiterable(self, itr):
More information about the pypy-commit
mailing list