[pypy-commit] pypy rpython-hash: oups, the 'for_testing' logic was never invoked

arigo pypy.commits at gmail.com
Sat Jan 28 03:20:08 EST 2017


Author: Armin Rigo <arigo at tunes.org>
Branch: rpython-hash
Changeset: r89814:84a5e4471eab
Date: 2017-01-28 00:08 +0100
http://bitbucket.org/pypy/pypy/changeset/84a5e4471eab/

Log:	oups, the 'for_testing' logic was never invoked

diff --git a/pypy/module/_cffi_backend/newtype.py b/pypy/module/_cffi_backend/newtype.py
--- a/pypy/module/_cffi_backend/newtype.py
+++ b/pypy/module/_cffi_backend/newtype.py
@@ -23,13 +23,14 @@
 # ____________________________________________________________
 
 class UniqueCache:
+    for_testing = False    # set to True on the class level in test_c.py
+
     def __init__(self, space):
         self.ctvoid = None      # Cache for the 'void' type
         self.ctvoidp = None     # Cache for the 'void *' type
         self.ctchara = None     # Cache for the 'char[]' type
         self.primitives = {}    # Cache for {name: primitive_type}
         self.functions = []     # see _new_function_type()
-        self.for_testing = False
 
 def _clean_cache(space):
     "NOT_RPYTHON"
diff --git a/pypy/module/_cffi_backend/test/test_c.py b/pypy/module/_cffi_backend/test/test_c.py
--- a/pypy/module/_cffi_backend/test/test_c.py
+++ b/pypy/module/_cffi_backend/test/test_c.py
@@ -36,6 +36,7 @@
     def setup_class(cls):
         testfuncs_w = []
         keepalive_funcs = []
+        UniqueCache.for_testing = True
 
         def find_and_load_library_for_test(space, w_name, w_is_global=None):
             if w_is_global is None:
@@ -86,11 +87,12 @@
             _all_test_c.find_and_load_library = func
             _all_test_c._testfunc = testfunc
         """)
-        UniqueCache.for_testing = True
 
     def teardown_method(self, method):
+        _clean_cache(self.space)
+
+    def teardown_class(cls):
         UniqueCache.for_testing = False
-        _clean_cache(self.space)
 
 
 all_names = ', '.join(Module.interpleveldefs.keys())


More information about the pypy-commit mailing list