Files
awx/awxkit/tox.ini
Lila Yasin 6d665dda33 Fix awxkit tox test failure caused by root pytest.ini config bleed (#16520)
Forward-port of ansible/tower#7537 for the devel branch.

When running awxkit's tox tests, pytest picks up the root pytest.ini
which pulls in pytest-django options (--reuse-db, --nomigrations,
DJANGO_SETTINGS_MODULE) and Django-specific filterwarnings.  Since the
awxkit tox environment does not install Django or pytest-django, these
cause test collection to fail.

The root cause is that pytest.ini has absolute priority in pytest's
config discovery — it searches all ancestor directories for pytest.ini
before falling back to tox.ini's [pytest] section.  A [pytest] section
in awxkit/tox.ini alone cannot prevent the root config from being used.

Fix by:
- Adding awxkit/pytest.ini to act as the primary config boundary
  (pytest.ini has the highest priority in config discovery, so its
  presence in awxkit/ stops the upward search before reaching root)
- Adding explicit `test` path argument to the pytest command in
  awxkit/tox.ini so pytest discovers tests correctly
- Adding `testpaths` and `python_files` to the [pytest] section in
  awxkit/tox.ini as a secondary config boundary
- Adding awxkit/conftest.py that registers the Django-specific CLI
  options and INI keys as harmless no-ops, as a further safety net

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-06-24 10:42:23 -04:00

54 lines
945 B
INI

[tox]
distshare = {homedir}/.tox/distshare
envlist =
lint,
test
skip_missing_interpreters = true
# recreate = true
# skipsdist = true
[testenv]
basepython = python3.12
setenv =
PYTHONPATH = {toxinidir}:{env:PYTHONPATH:}:.
deps =
websocket-client
coverage
mock
pytest
pytest-mock
commands =
coverage run --parallel --source awxkit -m pytest -c pytest.ini test --doctest-glob='*.md' --junit-xml=report.xml {posargs}
coverage combine
coverage xml
[testenv:lint]
deps =
{[testenv]deps}
flake8
commands =
flake8 awxkit
# pylama --report report.pylama awxkit
# py.test awxkit --pylama --junitxml=report.pylama {posargs}
- coverage erase
[testenv:coveralls]
commands=
- coverage combine
- coverage report -m
- coveralls
[flake8]
max-line-length = 120
[pytest]
addopts = -v --tb=native
testpaths = test
python_files = test_*.py
filterwarnings =
error
junit_family=xunit2