Skip to content

Commit 21dda09

Browse files
authored
gh-108303: Add Lib/test/test_cppext/ sub-directory (#108325)
* Move test_cppext to its own directory * Rename setup_testcppext.py to setup.py * Rename _testcppext.cpp to extension.cpp * The source (extension.cpp) is now also copied by the test.
1 parent c1c9cd6 commit 21dda09

File tree

4 files changed

+8
-6
lines changed

4 files changed

+8
-6
lines changed

Lib/test/test_cppext.py renamed to Lib/test/test_cppext/__init__.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,8 @@
1010

1111

1212
MS_WINDOWS = (sys.platform == 'win32')
13-
14-
15-
SETUP_TESTCPPEXT = support.findfile('setup_testcppext.py')
13+
SOURCE = os.path.join(os.path.dirname(__file__), 'extension.cpp')
14+
SETUP = os.path.join(os.path.dirname(__file__), 'setup.py')
1615

1716

1817
@support.requires_subprocess()
@@ -41,7 +40,8 @@ def check_build(self, std_cpp03, extension_name):
4140
def _check_build(self, std_cpp03, extension_name, python_exe):
4241
pkg_dir = 'pkg'
4342
os.mkdir(pkg_dir)
44-
shutil.copy(SETUP_TESTCPPEXT, os.path.join(pkg_dir, "setup.py"))
43+
shutil.copy(SETUP, os.path.join(pkg_dir, os.path.basename(SETUP)))
44+
shutil.copy(SOURCE, os.path.join(pkg_dir, os.path.basename(SOURCE)))
4545

4646
def run_cmd(operation, cmd):
4747
env = os.environ.copy()

Lib/test/_testcppext.cpp renamed to Lib/test/test_cppext/extension.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// gh-91321: Very basic C++ test extension to check that the Python C API is
22
// compatible with C++ and does not emit C++ compiler warnings.
3+
//
4+
// The code is only built, not executed.
35

46
// Always enable assertions
57
#undef NDEBUG

Lib/test/setup_testcppext.py renamed to Lib/test/test_cppext/setup.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,14 @@
22
# compatible with C++ and does not emit C++ compiler warnings.
33
import os
44
import sys
5-
from test import support
65

76
from setuptools import setup, Extension
87

98

109
MS_WINDOWS = (sys.platform == 'win32')
1110

1211

13-
SOURCE = support.findfile('_testcppext.cpp')
12+
SOURCE = 'extension.cpp'
1413
if not MS_WINDOWS:
1514
# C++ compiler flags for GCC and clang
1615
CPPFLAGS = [

Makefile.pre.in

+1
Original file line numberDiff line numberDiff line change
@@ -2156,6 +2156,7 @@ TESTSUBDIRS= idlelib/idle_test \
21562156
test/support/_hypothesis_stubs \
21572157
test/test_asyncio \
21582158
test/test_capi \
2159+
test/test_cppext \
21592160
test/test_ctypes \
21602161
test/test_email \
21612162
test/test_email/data \

0 commit comments

Comments
 (0)