[pypy-commit] pypy buffer-interface2: reset warnings filter after test

mattip pypy.commits at gmail.com
Wed Oct 5 15:46:53 EDT 2016


Author: Matti Picus <matti.picus at gmail.com>
Branch: buffer-interface2
Changeset: r87604:4fa1602ac181
Date: 2016-10-05 22:41 +0300
http://bitbucket.org/pypy/pypy/changeset/4fa1602ac181/

Log:	reset warnings filter after test

diff --git a/pypy/module/cpyext/test/test_memoryobject.py b/pypy/module/cpyext/test/test_memoryobject.py
--- a/pypy/module/cpyext/test/test_memoryobject.py
+++ b/pypy/module/cpyext/test/test_memoryobject.py
@@ -47,8 +47,6 @@
 
     @pytest.mark.skipif(only_pypy, reason='pypy only test')
     def test_buffer_info(self):
-        import warnings
-        warnings.filterwarnings("error")
         try:
             from _numpypy import multiarray as np
         except ImportError:
@@ -76,10 +74,15 @@
              )
         x = np.arange(dt1.itemsize, dtype='int8').view(dt1)
         # pytest can catch warnings from v2.8 and up, we ship 2.5
+        import warnings
+        warnings.filterwarnings("error")
         try:
-            y = get_buffer_info(x, ['SIMPLE'])
-        except UserWarning as e:
-            pass
-        else:
-            assert False ,"PyPy-specific UserWarning not raised" \
+            try:
+                y = get_buffer_info(x, ['SIMPLE'])
+            except UserWarning as e:
+                pass
+            else:
+                assert False ,"PyPy-specific UserWarning not raised" \
                           " on too long format string"
+        finally:
+            warnings.resetwarnings()


More information about the pypy-commit mailing list