[pypy-commit] pypy py3.3: Fix test by inserting sys.meta_path hook at the beginning.

mjacob pypy.commits at gmail.com
Mon Feb 15 12:04:50 EST 2016


Author: Manuel Jacob <me at manueljacob.de>
Branch: py3.3
Changeset: r82269:3495c617f6d0
Date: 2016-02-15 17:16 +0100
http://bitbucket.org/pypy/pypy/changeset/3495c617f6d0/

Log:	Fix test by inserting sys.meta_path hook at the beginning.

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
@@ -1040,7 +1040,7 @@
         import sys, math
         del sys.modules["math"]
 
-        sys.meta_path.append(Importer())
+        sys.meta_path.insert(0, Importer())
         try:
             import math
             assert len(tried_imports) == 1
@@ -1050,7 +1050,7 @@
             else:
                 assert tried_imports[0][0] == "math"
         finally:
-            sys.meta_path.pop()
+            sys.meta_path.pop(0)
 
     def test_meta_path_block(self):
         class ImportBlocker(object):
@@ -1069,7 +1069,7 @@
         if modname in sys.modules:
             mod = sys.modules
             del sys.modules[modname]
-        sys.meta_path.append(ImportBlocker(modname))
+        sys.meta_path.insert(0, ImportBlocker(modname))
         try:
             raises(ImportError, __import__, modname)
             # the imp module doesn't use meta_path, and is not blocked
@@ -1077,7 +1077,7 @@
             file, filename, stuff = imp.find_module(modname)
             imp.load_module(modname, file, filename, stuff)
         finally:
-            sys.meta_path.pop()
+            sys.meta_path.pop(0)
             if mod:
                 sys.modules[modname] = mod
 


More information about the pypy-commit mailing list