[pypy-commit] pypy py3k: rewrite this test by using directly _warnings instead of warnings: it's a considerable speedup, and import warnings did not ultimately work because the stdlib itertools module is shadowed by our testing package

antocuni noreply at buildbot.pypy.org
Tue Feb 28 12:21:17 CET 2012


Author: Antonio Cuni <anto.cuni at gmail.com>
Branch: py3k
Changeset: r52966:282563d7352d
Date: 2012-02-28 12:20 +0100
http://bitbucket.org/pypy/pypy/changeset/282563d7352d/

Log:	rewrite this test by using directly _warnings instead of warnings:
	it's a considerable speedup, and import warnings did not ultimately
	work because the stdlib itertools module is shadowed by our testing
	package

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
@@ -176,13 +176,15 @@
         def imp():
             import notapackage
 
-        import warnings
-        
-        warnings.simplefilter('error', ImportWarning)
+        import _warnings
+        def simplefilter(action, category):
+            _warnings.filters.insert(0, (action, None, category, None, 0))
+            
+        simplefilter('error', ImportWarning)
         try:
             raises(ImportWarning, imp)
         finally:
-            warnings.simplefilter('default', ImportWarning)
+            simplefilter('default', ImportWarning)
 
     def test_import_sys(self):
         import sys


More information about the pypy-commit mailing list