Skip to content

Make tox run the tests in generated packages - #716

Open
simonvanlierde wants to merge 2 commits into
NLeSC:mainfrom
simonvanlierde:fix/tox-run-tests
Open

simonvanlierde wants to merge 2 commits into
NLeSC:mainfrom
simonvanlierde:fix/tox-run-tests

Conversation

@simonvanlierde

Copy link
Copy Markdown

Checklist before requesting a review

  • I have read the contribution guidelines
  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas (nothing hard to follow: two lines move to another table)
  • I have made corresponding changes to the documentation (none needed: README.dev.md already says tox runs the tests)
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • All user facing changes have been added to CHANGELOG.md

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

List of related issues or pull requests**

Refs:

Describe the changes made in this pull request

Hi all,

tox in a generated package passed without running any tests. This fixes that, as discussed in #714.

  • The table in template/pyproject.toml.jinja was spelled [tool.box.testenv], so tox ignored its description and commands. I moved both keys into [tool.tox.env_run_base], next to dependency_groups.
  • test_tox only checked for "congratulations :)", which tox prints whether or not pytest ran. It now also checks for == 3 passed in, the same check test_pytest uses. On main's template that new check fails; tox's output there has no pytest lines.

CI will fail test_ruff_check until #713 is in; that failure is on main too.

Tests: the full template suite passes (12 passed) on Python 3.12, 3.13 and 3.14 in a Linux container, installed and run as in tests.yml, with #713's CPY001 ignore applied. I couldn't run the macOS and Windows jobs locally.

Best,
Simon

Instructions to review the pull request

Install the requirements

cd $(mktemp -d --tmpdir py-tmpl-XXXXXX)
pip install pipx
pipx install copier

Create a new package using the template

copier copy --vcs-ref fix/tox-run-tests https://github.com/simonvanlierde/python-template test_package

Create a local git repo to push to GitHub to trigger CI actions

git init
git add --all
git commit -m "First commit"
git remote add origin git@github.com:<YOU>/python-template-test.git
git push -u origin main -f
# Create a local environment to test your generated package locally
python -m venv env
source env/bin/activate
python -m pip install --upgrade pip setuptools
python -m pip install '.[dev,publishing]'

Then run tox -e py312 in test_package: the output now has pytest's 3 passed line before congratulations :).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tox in a generated package runs no tests

1 participant