Skip to content

Add test to run tox warning-free in a subprocess. #564

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions tests/test_package_generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,3 +151,30 @@ def test_docs_build(
assert tox_docs_process.returncode == 0, (
f"Something went wrong with building docs: {tox_docs_process.stderr!r}"
)


def test_package_tests_tox(
venv: pytest_venv.VirtualEnvironment,
generate_package: typing.Callable,
) -> None:
"""
Test that the package tests pass in all tox environments.

...and that no warnings are raised (e.g. coverage).
"""
_, test_project_dir = generate_package()
venv.install("tox")

tox_multienv_test_process = subprocess.run( # noqa: S603
[pathlib.Path(venv.bin) / "tox"],
check=False,
cwd=test_project_dir,
capture_output=True,
)

tests_pass = tox_multienv_test_process.returncode == 0
assert tests_pass, "Template tests failed in one or more tox environments."

return
output = tox_multienv_test_process.stdout.decode()
Comment on lines +178 to +179
Copy link
Preview

Copilot AI Jul 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This assertion checks stdout for warnings, but many tools including tox typically output warnings to stderr. The warning check should examine stderr instead of stdout.

Suggested change
return
output = tox_multienv_test_process.stdout.decode()
output = tox_multienv_test_process.stderr.decode()

Copilot uses AI. Check for mistakes.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should check both.

assert "WARNING:" not in output, f"Warnings raised during tests: {output}"
Loading