Skip to content

Commit b879d33

Browse files
committed
chore: rework single python tests
1 parent ba8be0d commit b879d33

12 files changed

+111
-118
lines changed

test/test_build_frontend_args.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,8 @@ def test_build_frontend_args(tmp_path, capfd, frontend_name):
1616
with pytest.raises(subprocess.CalledProcessError):
1717
utils.cibuildwheel_run(
1818
project_dir,
19-
add_env={
20-
"CIBW_BUILD": "cp311-*",
21-
"CIBW_BUILD_FRONTEND": f"{frontend_name}; args: -h",
22-
},
19+
add_env={"CIBW_BUILD_FRONTEND": f"{frontend_name}; args: -h"},
20+
single_python=True,
2321
)
2422

2523
captured = capfd.readouterr()

test/test_build_skip.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66

77
project_with_skip_asserts = test_projects.new_c_project(
88
setup_py_add=textwrap.dedent(
9-
r"""
10-
# explode if run on PyPyor Python 3.7 (these should be skipped)
9+
rf"""
1110
if sys.implementation.name != "cpython":
1211
raise Exception("Only CPython shall be built")
13-
if sys.version_info[0:2] == (3, 7):
14-
raise Exception("CPython 3.7 should be skipped")
12+
expected_version = {"({}, {})".format(*utils.SINGLE_PYTHON_VERSION)}
13+
if sys.version_info[0:2] != expected_version:
14+
raise Exception("CPython {{}}.{{}} should be skipped".format(*sys.version_info[0:2]))
1515
"""
1616
)
1717
)
@@ -21,17 +21,19 @@ def test(tmp_path):
2121
project_dir = tmp_path / "project"
2222
project_with_skip_asserts.generate(project_dir)
2323

24+
skip = " ".join(
25+
f"cp3{minor}-*" for minor in range(6, 30) if (3, minor) != utils.SINGLE_PYTHON_VERSION
26+
)
27+
2428
# build the wheels
2529
actual_wheels = utils.cibuildwheel_run(
2630
project_dir,
2731
add_env={
2832
"CIBW_BUILD": "cp3*-*",
29-
"CIBW_SKIP": "cp37-*",
33+
"CIBW_SKIP": f"*t-* {skip}",
3034
},
3135
)
3236

33-
# check that we got the right wheels. There should be no PyPy or 3.7.
34-
expected_wheels = [
35-
w for w in utils.expected_wheels("spam", "0.1.0") if ("-cp3" in w) and ("-cp37" not in w)
36-
]
37+
# check that we got the right wheels. There should be a single version of CPython.
38+
expected_wheels = utils.expected_wheels("spam", "0.1.0", single_python=True)
3739
assert set(actual_wheels) == set(expected_wheels)

test/test_container_engine.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,16 @@ def test_podman(tmp_path, capfd, request):
2121
actual_wheels = utils.cibuildwheel_run(
2222
project_dir,
2323
add_env={
24-
"CIBW_BUILD": "cp310-*{manylinux,musllinux}_x86_64",
24+
"CIBW_ARCHS": "x86_64",
2525
"CIBW_BEFORE_ALL": "echo 'test log statement from before-all'",
2626
"CIBW_CONTAINER_ENGINE": "podman",
2727
},
28+
single_python=True,
2829
)
2930

3031
# check that the expected wheels are produced
3132
expected_wheels = [
32-
w
33-
for w in utils.expected_wheels("spam", "0.1.0")
34-
if ("-cp310-" in w) and ("x86_64" in w) and ("manylinux" in w or "musllinux" in w)
33+
w for w in utils.expected_wheels("spam", "0.1.0", single_python=True) if "x86_64" in w
3534
]
3635
assert set(actual_wheels) == set(expected_wheels)
3736

@@ -51,15 +50,16 @@ def test_create_args(tmp_path, capfd):
5150
actual_wheels = utils.cibuildwheel_run(
5251
project_dir,
5352
add_env={
54-
"CIBW_BUILD": "cp310-manylinux_*",
53+
"CIBW_SKIP": "*-musllinux_*",
5554
"CIBW_BEFORE_ALL": "echo TEST_CREATE_ARGS is set to $TEST_CREATE_ARGS",
5655
"CIBW_CONTAINER_ENGINE": "docker; create_args: --env=TEST_CREATE_ARGS=itworks",
5756
},
57+
single_python=True,
5858
)
5959

60-
expected_wheels = [
61-
w for w in utils.expected_wheels("spam", "0.1.0") if ("cp310-manylinux" in w)
62-
]
60+
expected_wheels = utils.expected_wheels(
61+
"spam", "0.1.0", musllinux_versions=[], single_python=True
62+
)
6363
assert set(actual_wheels) == set(expected_wheels)
6464

6565
captured = capfd.readouterr()

test/test_cpp_standards.py

Lines changed: 27 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -56,76 +56,62 @@
5656
cpp_test_project.files["setup.py"] = jinja2.Template(setup_py_template)
5757
cpp_test_project.files["spam.cpp"] = jinja2.Template(spam_cpp_template)
5858

59-
cpp11_project = cpp_test_project.copy()
60-
cpp11_project.template_context["extra_compile_args"] = (
61-
["/std:c++11"] if utils.platform == "windows" else ["-std=c++11"]
62-
)
63-
cpp11_project.template_context["spam_cpp_top_level_add"] = "#include <array>"
64-
6559

6660
def test_cpp11(tmp_path):
6761
# This test checks that the C++11 standard is supported
6862
project_dir = tmp_path / "project"
69-
63+
cpp11_project = cpp_test_project.copy()
64+
cpp11_project.template_context["extra_compile_args"] = (
65+
["/std:c++11"] if utils.platform == "windows" else ["-std=c++11"]
66+
)
67+
cpp11_project.template_context["spam_cpp_top_level_add"] = "#include <array>"
7068
cpp11_project.generate(project_dir)
7169

72-
actual_wheels = utils.cibuildwheel_run(project_dir)
73-
expected_wheels = list(utils.expected_wheels("spam", "0.1.0"))
70+
actual_wheels = utils.cibuildwheel_run(project_dir, single_python=True)
71+
expected_wheels = utils.expected_wheels("spam", "0.1.0", single_python=True)
7472

7573
assert set(actual_wheels) == set(expected_wheels)
7674

7775

78-
cpp14_project = cpp_test_project.copy()
79-
cpp14_project.template_context["extra_compile_args"] = (
80-
["/std:c++14"] if utils.platform == "windows" else ["-std=c++14"]
81-
)
82-
cpp14_project.template_context["spam_cpp_top_level_add"] = "int a = 100'000;"
83-
84-
8576
def test_cpp14(tmp_path):
8677
# This test checks that the C++14 standard is supported
8778
project_dir = tmp_path / "project"
88-
79+
cpp14_project = cpp_test_project.copy()
80+
cpp14_project.template_context["extra_compile_args"] = (
81+
["/std:c++14"] if utils.platform == "windows" else ["-std=c++14"]
82+
)
83+
cpp14_project.template_context["spam_cpp_top_level_add"] = "int a = 100'000;"
8984
cpp14_project.generate(project_dir)
9085

91-
actual_wheels = utils.cibuildwheel_run(project_dir)
92-
expected_wheels = list(utils.expected_wheels("spam", "0.1.0"))
86+
actual_wheels = utils.cibuildwheel_run(project_dir, single_python=True)
87+
expected_wheels = utils.expected_wheels("spam", "0.1.0", single_python=True)
9388

9489
assert set(actual_wheels) == set(expected_wheels)
9590

9691

97-
cpp17_project = cpp_test_project.copy()
98-
99-
cpp17_project.template_context["extra_compile_args"] = [
100-
"/std:c++17" if utils.platform == "windows" else "-std=c++17"
101-
]
102-
cpp17_project.template_context["spam_cpp_top_level_add"] = r"""
103-
#include <utility>
104-
auto a = std::pair(5.0, false);
105-
"""
106-
107-
10892
def test_cpp17(tmp_path):
10993
# This test checks that the C++17 standard is supported
11094
project_dir = tmp_path / "project"
111-
95+
cpp17_project = cpp_test_project.copy()
96+
cpp17_project.template_context["extra_compile_args"] = [
97+
"/std:c++17" if utils.platform == "windows" else "-std=c++17"
98+
]
99+
cpp17_project.template_context["spam_cpp_top_level_add"] = r"""
100+
#include <utility>
101+
auto a = std::pair(5.0, false);
102+
"""
112103
cpp17_project.generate(project_dir)
113104

114105
if os.environ.get("APPVEYOR_BUILD_WORKER_IMAGE", "") == "Visual Studio 2015":
115106
pytest.skip("Visual Studio 2015 does not support C++17")
116107

117-
# Pypy's distutils sets the default compiler to 'msvc9compiler', which
118-
# is too old to support cpp17.
119-
add_env = {"CIBW_SKIP": "pp*"}
120-
108+
add_env = {}
121109
if utils.platform == "macos":
122110
add_env["MACOSX_DEPLOYMENT_TARGET"] = "10.13"
123111

124-
actual_wheels = utils.cibuildwheel_run(project_dir, add_env=add_env)
125-
expected_wheels = [
126-
w
127-
for w in utils.expected_wheels("spam", "0.1.0", macosx_deployment_target="10.13")
128-
if "-pp" not in w
129-
]
112+
actual_wheels = utils.cibuildwheel_run(project_dir, add_env=add_env, single_python=True)
113+
expected_wheels = utils.expected_wheels(
114+
"spam", "0.1.0", macosx_deployment_target="10.13", single_python=True
115+
)
130116

131117
assert set(actual_wheels) == set(expected_wheels)

test/test_environment.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,11 @@ def test(tmp_path):
4949
"CIBW_ENVIRONMENT": """CIBW_TEST_VAR="a b c" CIBW_TEST_VAR_2=1 CIBW_TEST_VAR_3="$(echo 'test string 3')" PATH=$PATH:/opt/cibw_test_path""",
5050
"CIBW_ENVIRONMENT_WINDOWS": f'''CIBW_TEST_VAR="a b c" CIBW_TEST_VAR_2=1 CIBW_TEST_VAR_3="$({python_echo} 'test string 3')" PATH="$PATH;/opt/cibw_test_path"''',
5151
},
52+
single_python=True,
5253
)
5354

5455
# also check that we got the right wheels built
55-
expected_wheels = utils.expected_wheels("spam", "0.1.0")
56+
expected_wheels = utils.expected_wheels("spam", "0.1.0", single_python=True)
5657
assert set(actual_wheels) == set(expected_wheels)
5758

5859

@@ -133,12 +134,12 @@ def test_overridden_pip_constraint(tmp_path, build_frontend):
133134
actual_wheels = utils.cibuildwheel_run(
134135
project_dir,
135136
add_env={
136-
"CIBW_BUILD": "cp312-*",
137137
"CIBW_BUILD_FRONTEND": build_frontend,
138138
"PIP_CONSTRAINT": str(constraints_file),
139139
"CIBW_ENVIRONMENT_LINUX": "PIP_CONSTRAINT=./constraints.txt",
140140
},
141+
single_python=True,
141142
)
142143

143-
expected_wheels = [w for w in utils.expected_wheels("spam", "0.1.0") if "cp312" in w]
144+
expected_wheels = utils.expected_wheels("spam", "0.1.0", single_python=True)
144145
assert set(actual_wheels) == set(expected_wheels)

test/test_from_sdist.py

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ def cibuildwheel_from_sdist_run(sdist_path, add_env=None, config_file=None):
3333
if add_env:
3434
env.update(add_env)
3535

36+
env["CIBW_BUILD"] = "cp{}{}-*".format(*utils.SINGLE_PYTHON_VERSION)
37+
3638
with TemporaryDirectory() as tmp_output_dir:
3739
subprocess.run(
3840
[
@@ -73,15 +75,11 @@ def test_simple(tmp_path):
7375

7476
# build the wheels from sdist
7577
actual_wheels = cibuildwheel_from_sdist_run(
76-
sdist_path,
77-
add_env={
78-
"CIBW_BEFORE_BUILD": setup_py_assertion_cmd,
79-
"CIBW_BUILD": "cp39-*",
80-
},
78+
sdist_path, add_env={"CIBW_BEFORE_BUILD": setup_py_assertion_cmd}
8179
)
8280

8381
# check that the expected wheels are produced
84-
expected_wheels = [w for w in utils.expected_wheels("spam", "0.1.0") if "cp39" in w]
82+
expected_wheels = utils.expected_wheels("spam", "0.1.0", single_python=True)
8583
assert set(actual_wheels) == set(expected_wheels)
8684

8785

@@ -105,14 +103,10 @@ def test_external_config_file_argument(tmp_path, capfd):
105103
)
106104

107105
# build the wheels from sdist
108-
actual_wheels = cibuildwheel_from_sdist_run(
109-
sdist_path,
110-
add_env={"CIBW_BUILD": "cp39-*"},
111-
config_file=str(config_file),
112-
)
106+
actual_wheels = cibuildwheel_from_sdist_run(sdist_path, config_file=str(config_file))
113107

114108
# check that the expected wheels are produced
115-
expected_wheels = [w for w in utils.expected_wheels("spam", "0.1.0") if "cp39" in w]
109+
expected_wheels = utils.expected_wheels("spam", "0.1.0", single_python=True)
116110
assert set(actual_wheels) == set(expected_wheels)
117111

118112
# check that before-all was run
@@ -136,13 +130,10 @@ def test_config_in_pyproject_toml(tmp_path, capfd):
136130
sdist_path = make_sdist(project, sdist_dir)
137131

138132
# build the wheels from sdist
139-
actual_wheels = cibuildwheel_from_sdist_run(
140-
sdist_path,
141-
add_env={"CIBW_BUILD": "cp39-*"},
142-
)
133+
actual_wheels = cibuildwheel_from_sdist_run(sdist_path)
143134

144135
# check that the expected wheels are produced
145-
expected_wheels = [w for w in utils.expected_wheels("spam", "0.1.0") if "cp39" in w]
136+
expected_wheels = utils.expected_wheels("spam", "0.1.0", single_python=True)
146137
assert set(actual_wheels) == set(expected_wheels)
147138

148139
# check that before-build was run
@@ -174,13 +165,11 @@ def test_internal_config_file_argument(tmp_path, capfd):
174165

175166
# build the wheels from sdist, referencing the config file inside
176167
actual_wheels = cibuildwheel_from_sdist_run(
177-
sdist_path,
178-
add_env={"CIBW_BUILD": "cp39-*"},
179-
config_file="{package}/wheel_build_config.toml",
168+
sdist_path, config_file="{package}/wheel_build_config.toml"
180169
)
181170

182171
# check that the expected wheels are produced
183-
expected_wheels = [w for w in utils.expected_wheels("spam", "0.1.0") if "cp39" in w]
172+
expected_wheels = utils.expected_wheels("spam", "0.1.0", single_python=True)
184173
assert set(actual_wheels) == set(expected_wheels)
185174

186175
# check that before-all was run

0 commit comments

Comments
 (0)