2022-07-14 13:36:57 +02:00
|
|
|
from __future__ import annotations
|
|
|
|
|
|
2020-07-20 15:35:51 +01:00
|
|
|
import subprocess
|
2021-01-06 13:50:58 -05:00
|
|
|
|
|
|
|
|
import pytest
|
|
|
|
|
|
2024-05-27 22:34:22 -04:00
|
|
|
from test import test_projects
|
|
|
|
|
|
2020-07-20 15:35:51 +01:00
|
|
|
from . import utils
|
|
|
|
|
|
|
|
|
|
pure_python_project = test_projects.TestProject()
|
2023-10-27 01:21:20 -04:00
|
|
|
pure_python_project.files["setup.py"] = """
|
2020-07-20 15:35:51 +01:00
|
|
|
from setuptools import Extension, setup
|
|
|
|
|
|
|
|
|
|
setup(
|
|
|
|
|
name="spam",
|
|
|
|
|
py_modules=['spam'],
|
|
|
|
|
version="0.1.0",
|
|
|
|
|
)
|
2021-05-03 11:45:43 -04:00
|
|
|
"""
|
2020-07-20 15:35:51 +01:00
|
|
|
|
2023-10-27 01:21:20 -04:00
|
|
|
pure_python_project.files["spam.py"] = """
|
2020-07-20 15:35:51 +01:00
|
|
|
def a_function():
|
|
|
|
|
pass
|
2021-05-03 11:45:43 -04:00
|
|
|
"""
|
2020-07-20 15:35:51 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def test(tmp_path, capfd):
|
|
|
|
|
# this test checks that if a pure wheel is generated, the build should
|
|
|
|
|
# fail.
|
2021-05-03 11:45:43 -04:00
|
|
|
project_dir = tmp_path / "project"
|
2020-07-20 15:35:51 +01:00
|
|
|
pure_python_project.generate(project_dir)
|
|
|
|
|
|
|
|
|
|
with pytest.raises(subprocess.CalledProcessError):
|
2023-01-30 15:53:44 -05:00
|
|
|
print("produced wheels:", utils.cibuildwheel_run(project_dir))
|
2020-07-20 15:35:51 +01:00
|
|
|
|
|
|
|
|
captured = capfd.readouterr()
|
2021-05-03 11:45:43 -04:00
|
|
|
print("out", captured.out)
|
|
|
|
|
print("err", captured.err)
|
2020-07-20 15:35:51 +01:00
|
|
|
assert "Build failed because a pure Python wheel was generated" in captured.err
|