[pypy-commit] pypy py3.5: Tweak test until it passes with -A.

arigo pypy.commits at gmail.com
Mon Nov 21 08:35:15 EST 2016


Author: Armin Rigo <arigo at tunes.org>
Branch: py3.5
Changeset: r88520:3ef2278cf711
Date: 2016-11-21 12:30 +0100
http://bitbucket.org/pypy/pypy/changeset/3ef2278cf711/

Log:	Tweak test until it passes with -A.

diff --git a/pypy/module/imp/test/test_import.py b/pypy/module/imp/test/test_import.py
--- a/pypy/module/imp/test/test_import.py
+++ b/pypy/module/imp/test/test_import.py
@@ -75,6 +75,9 @@
              abs_sys    = "import sys",
              struct     = "inpackage = 1",
              errno      = "",
+             # Python 3 note: this __future__ has no effect any more,
+             # kept around for testing and to avoid increasing the diff
+             # with PyPy2
              absolute   = "from __future__ import absolute_import\nimport struct",
              relative_b = "from __future__ import absolute_import\nfrom . import struct",
              relative_c = "from __future__ import absolute_import\nfrom .struct import inpackage",
@@ -597,7 +600,7 @@
         imp.reload(sys)
 
         assert sys.path is oldpath
-        assert 'settrace' in dir(sys)
+        assert 'settrace' not in dir(sys)    # at least on CPython 3.5.2
 
     def test_reload_builtin_doesnt_clear(self):
         import imp
@@ -657,16 +660,15 @@
             assert False, 'should not work'
 
     def test_cache_from_source(self):
-        import imp
+        import imp, sys
+        tag = sys.implementation.cache_tag
         pycfile = imp.cache_from_source('a/b/c.py')
-        assert pycfile.startswith('a/b/__pycache__/c.pypy3-')
-        assert pycfile.endswith('.pyc')
-        assert imp.source_from_cache('a/b/__pycache__/c.pypy3-17.pyc'
+        assert pycfile == 'a/b/__pycache__/c.%s.pyc' % tag
+        assert imp.source_from_cache('a/b/__pycache__/c.%s.pyc' % tag
                                      ) == 'a/b/c.py'
         raises(ValueError, imp.source_from_cache, 'a/b/c.py')
 
     def test_invalid_pathname(self):
-        skip("This test fails on CPython 3.3, but passes on CPython 3.4+")
         import imp
         import pkg
         import os
@@ -906,6 +908,10 @@
             stream.close()
 
     def test_pyc_magic_changes(self):
+        # skipped: for now, PyPy generates only one kind of .pyc file
+        # per version.  Different versions should differ in
+        # sys.implementation.cache_tag, which means that they'll look up
+        # different .pyc files anyway.  See test_get_tag() in test_app.py.
         py.test.skip("For now, PyPy generates only one kind of .pyc files")
         # test that the pyc files produced by a space are not reimportable
         # from another, if they differ in what opcodes they support


More information about the pypy-commit mailing list