[pypy-svn] r74116 - pypy/branch/cpython-extension/pypy/module/cpyext/test
exarkun at codespeak.net
exarkun at codespeak.net
Tue Apr 27 18:29:07 CEST 2010
Author: exarkun
Date: Tue Apr 27 18:29:05 2010
New Revision: 74116
Modified:
pypy/branch/cpython-extension/pypy/module/cpyext/test/test_cpyext.py
Log:
Add a test for an extension module with a dotted name
Modified: pypy/branch/cpython-extension/pypy/module/cpyext/test/test_cpyext.py
==============================================================================
--- pypy/branch/cpython-extension/pypy/module/cpyext/test/test_cpyext.py (original)
+++ pypy/branch/cpython-extension/pypy/module/cpyext/test/test_cpyext.py Tue Apr 27 18:29:05 2010
@@ -132,7 +132,16 @@
cls.space = gettestobjspace(usemodules=['cpyext', 'thread'])
cls.space.getbuiltinmodule("cpyext")
- def import_module(self, name, init=None, body='', load_it=True):
+ def import_module(self, name, init=None, body='', load_it=True, filename=None):
+ """
+ init specifies the overall template of the module.
+
+ if init is None, the module source will be loaded from a file in this
+ test direcory, give a name given by the filename parameter.
+
+ if filename is None, the module name will be used to construct the
+ filename.
+ """
if init is not None:
code = """
#include <Python.h>
@@ -144,6 +153,8 @@
""" % dict(name=name, init=init, body=body)
kwds = dict(separate_module_sources=[code])
else:
+ if filename is not None:
+ name = filename
filename = py.path.local(autopath.pypydir) / 'module' \
/ 'cpyext'/ 'test' / (name + ".c")
kwds = dict(separate_module_files=[filename])
@@ -310,6 +321,18 @@
assert module.return_cookie() == 3.14
+ def test_InitModule4Dotted(self):
+ """
+ If the module name passed to Py_InitModule4 includes a package, only
+ the module name (the part after the last dot) is considered when
+ computing the name of the module initializer function.
+ """
+ skip("This is not supported at present.")
+ expected_name = "pypy.module.cpyext.test.dotted"
+ module = self.import_module(name=expected_name, filename="dotted")
+ assert module.__name__ == expected_name
+
+
def test_modinit_func(self):
"""
A module can use the PyMODINIT_FUNC macro to declare or define its
More information about the Pypy-commit
mailing list