Add test failure with descriptive error message when running tests without a {project} placeholder

This commit is contained in:
Joe Rickerby
2022-11-06 11:02:01 +00:00
parent 2e6cbe2435
commit e4cbe81f3f
6 changed files with 69 additions and 10 deletions
+27
View File
@@ -3,6 +3,7 @@ from __future__ import annotations
import os
import subprocess
import textwrap
from pathlib import Path
import pytest
@@ -151,3 +152,29 @@ def test_failing_test(tmp_path):
)
assert len(os.listdir(output_dir)) == 0
def test_bare_pytest_invocation(tmp_path: Path, capfd: pytest.CaptureFixture[str]):
"""Check that if a user runs pytest in the the test cwd, it raises a helpful error"""
project_dir = tmp_path / "project"
output_dir = tmp_path / "output"
project_with_a_test.generate(project_dir)
with pytest.raises(subprocess.CalledProcessError):
utils.cibuildwheel_run(
project_dir,
output_dir=output_dir,
add_env={
"CIBW_TEST_REQUIRES": "pytest",
"CIBW_TEST_COMMAND": "python -m pytest",
},
)
assert len(os.listdir(output_dir)) == 0
captured = capfd.readouterr()
assert (
"Please specify a path to your tests when invoking pytest using the {project} placeholder"
in captured.out
)