Skip to content

build: move the pytest settings into pyproject.toml - #960

Merged
cigamit merged 6 commits into
ctrliq:mainfrom
blaipr:build/pytest-and-coverage-into-pyproject
Sep 13, 2026
Merged

build: move the pytest settings into pyproject.toml#960
cigamit merged 6 commits into
ctrliq:mainfrom
blaipr:build/pytest-and-coverage-into-pyproject

Conversation

@blaipr

@blaipr blaipr commented Sep 13, 2026

Copy link
Copy Markdown
Contributor

Sits on #958, which edits .coveragerc; merge that first. The .coveragerc move is a separate pull request so the two can be reviewed, and reverted, on their own.

pyproject.toml already owns [tool.setuptools], [tool.setuptools_scm] and [tool.ruff], so pytest.ini becomes [tool.pytest.ini_options] and the file goes. tox.ini and .yamllint stay, since neither reads pyproject.toml.

One value changed, and it fixes 14 collection errors

pytest.ini set python_files to every .py, so collecting imported the whole repository looking for tests. That includes modules which parse argv at import time, and one of them takes the run down rather than reporting:

File "/awx_devel/tools/data_generators/rbac_dummy_data_generator.py", line 88, in <module>
    options, remainder = parser.parse_args()
  ...
INTERNALERROR> SystemExit: 2

Nobody has seen it because CI collects named paths rather than the tree.

Nothing needed the wider net. I checked every .py in the repository: not one file outside pytest's own patterns defines a test. The only two that look like they do are fixtures named test_* inside a conftest.py, which pytest never collects as a module anyway. So python_files is pytest's default now:

collecting the whole tree tests errors time
before 4,020 14 26.1s
after 4,020 0 8.5s

Same tests, no errors, and collection is three times faster because pytest stops importing the codebase to look for them.

Checks

  • All eight markers still register (ac, survey, inventory_import, defined_in_file, job_permissions, activity_stream_access, job_runtime_vars, fixture_args).
  • awx/main/tests/unit: passing.
  • README.md, CONTRIBUTING.md and .github/copilot-instructions.md pointed readers at pytest.ini and now point at pyproject.toml.

@blaipr
blaipr force-pushed the build/pytest-and-coverage-into-pyproject branch from f4a94b4 to 4b7c37a Compare September 13, 2026 00:37
@blaipr blaipr changed the title build: move the pytest and coverage settings into pyproject.toml build: move the pytest settings into pyproject.toml Sep 13, 2026
@blaipr
blaipr force-pushed the build/pytest-and-coverage-into-pyproject branch from 4b7c37a to 69f2cb3 Compare September 13, 2026 01:22
MANIFEST.in names eight paths that are not in the tree:

  awx/lib/site-packages, awx/plugins, awx/api/tests, awx/ui/client,
  awx/playbooks/library/mkfifo.py, awx/public, VERSION, COPYING

All inherited, and some of them long gone: awx/ui/client is the AngularJS UI,
which went years before the 22.5.0 import this fork starts from.

It only costs setuptools warnings, so the change is cosmetic in effect. What
it is not cosmetic about is trust: this is the file that decides what ships in
the sdist, and one that names eight things that do not exist reads as nobody's
business. After this every path it names is real.

.coveragerc carries the same rot in its omit list, awx/lib/site-packages/*, so
that goes in the same change.

Checked by building from a copy of the tree: setuptools reports no missing
path warnings afterwards.
pyproject already owns setuptools, setuptools_scm and ruff, so pytest.ini
becomes [tool.pytest.ini_options] and the file goes. tox.ini and .yamllint
stay, since neither reads pyproject. .coveragerc moves separately, so the two
can be reviewed and reverted on their own.

One value changed on the way, and it is the reason collection has been
reporting 14 errors. pytest.ini set python_files to every .py, so collecting
imported the whole repository looking for tests, including modules that parse
argv at import time. One of them, tools/data_generators/rbac_dummy_data_
generator.py, calls sys.exit(2) from optparse, which takes the whole run down
with an INTERNALERROR rather than reporting a failure. Nobody has seen it
because CI collects named paths rather than the tree.

Nothing needed that wider net. Not one file outside pytest's own patterns
defines a test: the only two that look like they do are fixtures named test_*
inside a conftest.py, which is never collected as a module anyway. So
python_files is pytest's default now, and collecting the tree gives the same
4,020 tests with no errors, in 8 seconds instead of 26.

  before   4,020 tests collected, 14 errors, 26.1s
  after    4,020 tests collected,  0 errors,  8.5s

Everything else is moved unchanged. All eight markers still register and the
unit suite passes.

README, CONTRIBUTING and the copilot instructions pointed readers at
pytest.ini and now point at pyproject.toml.
@blaipr
blaipr force-pushed the build/pytest-and-coverage-into-pyproject branch from 69f2cb3 to 3f74102 Compare September 13, 2026 08:58
@cigamit cigamit self-assigned this Sep 13, 2026
@cigamit
cigamit merged commit ccc04b5 into ctrliq:main Sep 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

2 participants