[pypy-commit] pypy test-cpyext: kill w_record_imported_module and unskip test_recursive_package_import() on -A
rlamy
pypy.commits at gmail.com
Thu Sep 8 18:13:55 EDT 2016
Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: test-cpyext
Changeset: r86968:9374f605480e
Date: 2016-09-08 23:13 +0100
http://bitbucket.org/pypy/pypy/changeset/9374f605480e/
Log: kill w_record_imported_module and unskip
test_recursive_package_import() on -A
diff --git a/pypy/module/cpyext/bufferobject.py b/pypy/module/cpyext/bufferobject.py
--- a/pypy/module/cpyext/bufferobject.py
+++ b/pypy/module/cpyext/bufferobject.py
@@ -61,6 +61,7 @@
py_buf.c_b_ptr = rffi.cast(rffi.VOIDP, buf.array._charbuf_start())
py_buf.c_b_size = buf.getlength()
else:
+ raise RuntimeError
raise oefmt(space.w_NotImplementedError, "buffer flavor not supported")
diff --git a/pypy/module/cpyext/test/test_cpyext.py b/pypy/module/cpyext/test/test_cpyext.py
--- a/pypy/module/cpyext/test/test_cpyext.py
+++ b/pypy/module/cpyext/test/test_cpyext.py
@@ -317,6 +317,15 @@
if not cls.runappdirect:
cls.w_runappdirect = space.wrap(cls.runappdirect)
+ def record_imported_module(self, name):
+ """
+ Record a module imported in a test so that it can be cleaned up in
+ teardown before the check for leaks is done.
+
+ name gives the name of the module in the space's sys.modules.
+ """
+ self.imported_module_names.append(name)
+
def setup_method(self, func):
@gateway.unwrap_spec(name=str)
def compile_module(space, name,
@@ -337,6 +346,11 @@
name,
source_files=source_files,
source_strings=source_strings)
+
+ # hackish, but tests calling compile_module() always end up
+ # importing the result
+ self.record_imported_module(name)
+
return space.wrap(pydname)
@gateway.unwrap_spec(name=str, init='str_or_None', body=str,
@@ -399,7 +413,7 @@
return imp.load_dynamic(name, mod)
else:
api.load_extension_module(space, mod, name)
- self.imported_module_names.append(name)
+ self.record_imported_module(name)
return space.getitem(
space.sys.get('modules'),
space.wrap(name))
@@ -429,16 +443,6 @@
w_include_dirs=w_include_dirs,
PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)
- @gateway.unwrap_spec(name=str)
- def record_imported_module(name):
- """
- Record a module imported in a test so that it can be cleaned up in
- teardown before the check for leaks is done.
-
- name gives the name of the module in the space's sys.modules.
- """
- self.imported_module_names.append(name)
-
def debug_collect(space):
rawrefcount._collect()
@@ -468,7 +472,6 @@
self.w_import_module = wrap(interp2app(import_module))
self.w_reimport_module = wrap(interp2app(reimport_module))
self.w_import_extension = wrap(interp2app(import_extension))
- self.w_record_imported_module = wrap(interp2app(record_imported_module))
self.w_here = wrap(str(py.path.local(pypydir)) + '/module/cpyext/test/')
self.w_debug_collect = wrap(interp2app(debug_collect))
@@ -621,15 +624,11 @@
If `cherry.date` is an extension module which imports `apple.banana`,
the latter is added to `sys.modules` for the `"apple.banana"` key.
"""
- if self.runappdirect:
- skip('record_imported_module not supported in runappdirect mode')
# Build the extensions.
banana = self.compile_module(
"apple.banana", source_files=[self.here + 'banana.c'])
- self.record_imported_module("apple.banana")
date = self.compile_module(
"cherry.date", source_files=[self.here + 'date.c'])
- self.record_imported_module("cherry.date")
# Set up some package state so that the extensions can actually be
# imported.
More information about the pypy-commit
mailing list