|
12 | 12 | from test import support |
13 | 13 |
|
14 | 14 |
|
15 | | -SOURCE = os.path.join(os.path.dirname(__file__), 'extension.c') |
| 15 | +SOURCES = [ |
| 16 | + os.path.join(os.path.dirname(__file__), 'extension.c'), |
| 17 | + os.path.join(os.path.dirname(__file__), 'create_moduledef.c'), |
| 18 | +] |
16 | 19 | SETUP = os.path.join(os.path.dirname(__file__), 'setup.py') |
17 | 20 |
|
18 | 21 |
|
@@ -51,24 +54,32 @@ def test_build_limited(self): |
51 | 54 | def test_build_limited_c11(self): |
52 | 55 | self.check_build('_test_limited_c11_cext', limited=True, std='c11') |
53 | 56 |
|
54 | | - def check_build(self, extension_name, std=None, limited=False): |
| 57 | + def test_build_opaque(self): |
| 58 | + # Test with _Py_OPAQUE_PYOBJECT |
| 59 | + self.check_build('_test_limited_opaque_cext', limited=True, opaque=True) |
| 60 | + |
| 61 | + def check_build(self, extension_name, std=None, limited=False, opaque=False): |
55 | 62 | venv_dir = 'env' |
56 | 63 | with support.setup_venv_with_pip_setuptools(venv_dir) as python_exe: |
57 | 64 | self._check_build(extension_name, python_exe, |
58 | | - std=std, limited=limited) |
| 65 | + std=std, limited=limited, opaque=opaque) |
59 | 66 |
|
60 | | - def _check_build(self, extension_name, python_exe, std, limited): |
| 67 | + def _check_build(self, extension_name, python_exe, std, limited, opaque): |
61 | 68 | pkg_dir = 'pkg' |
62 | 69 | os.mkdir(pkg_dir) |
63 | 70 | shutil.copy(SETUP, os.path.join(pkg_dir, os.path.basename(SETUP))) |
64 | | - shutil.copy(SOURCE, os.path.join(pkg_dir, os.path.basename(SOURCE))) |
| 71 | + for source in SOURCES: |
| 72 | + dest = os.path.join(pkg_dir, os.path.basename(source)) |
| 73 | + shutil.copy(source, dest) |
65 | 74 |
|
66 | 75 | def run_cmd(operation, cmd): |
67 | 76 | env = os.environ.copy() |
68 | 77 | if std: |
69 | 78 | env['CPYTHON_TEST_STD'] = std |
70 | 79 | if limited: |
71 | 80 | env['CPYTHON_TEST_LIMITED'] = '1' |
| 81 | + if opaque: |
| 82 | + env['CPYTHON_TEST_OPAQUE_PYOBJECT'] = '1' |
72 | 83 | env['CPYTHON_TEST_EXT_NAME'] = extension_name |
73 | 84 | if support.verbose: |
74 | 85 | print('Run:', ' '.join(map(shlex.quote, cmd))) |
|
0 commit comments