Files
cibuildwheel/test/test_pure_wheel.py
Henry Schreinerandpre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> 097806b6b1 tests: fully type the test suite (#2794)
* tests: fully type the test suite

* chore: require more typing

Signed-off-by: Henry Schreiner <henryfs@princeton.edu>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Signed-off-by: Henry Schreiner <henryfs@princeton.edu>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2026-04-01 15:23:02 +01:00

41 lines
1003 B
Python

import subprocess
from pathlib import Path
import pytest
from test import test_projects
from . import utils
pure_python_project = test_projects.TestProject()
pure_python_project.files["setup.py"] = """
from setuptools import Extension, setup
setup(
name="spam",
py_modules=['spam'],
version="0.1.0",
)
"""
pure_python_project.files["spam.py"] = """
def a_function():
pass
"""
def test(tmp_path: Path, capfd: pytest.CaptureFixture[str]) -> None:
# this test checks that if a pure wheel is generated, the build should
# fail.
project_dir = tmp_path / "project"
pure_python_project.generate(project_dir)
with pytest.raises(subprocess.CalledProcessError) as exc_info:
print("produced wheels:", utils.cibuildwheel_run(project_dir))
captured = capfd.readouterr()
print("out", captured.out)
print("err", captured.err)
assert exc_info.value.returncode == 5
assert "Build failed because a pure Python wheel was generated" in captured.err