Fix unit test failures under pytest 9.
Review Request #15228 — Created Aug. 13, 2026 and submitted
Since the pytest pin was removed, CI installs pytest 9 on any build
running Python 3.10 or higher (pytest 9 dropped support for older
Python versions). Those builds were failing every test that made an
HTTP request, while the Python 3.8 and 3.9 builds on pytest 8 passed.pytest 9 reworked fixture precedence and ordering. Our session-scoped
autousesetup_siteconfigfixture used to run beforedjango_db_setup,
but under pytest 9 that order is reversed. This ended up storing
incorrectMEDIA_ROOTandSTATIC_ROOTin the database, causing
several tests to fail because we were serving the
manual-updates-required page instead of intended content.This makes
django_db_setupdepend onsetup_siteconfigexplicitly, so
the paths are always configured before the siteconfig is created. That
no longer relies on autouse fixtures being ordered first.
Reproduced the fixture ordering change in isolation. pytest 8.3.5 runs
setup_siteconfigfirst, pytest 9.1.1 runsdjango_db_setupfirst, and
with this change both run in the correct order.Forced the pytest 9 ordering under pytest 8 to confirm the cause. That
reproduced the CI failures, with the same manual updates templates being
rendered.
| Summary | ID |
|---|---|
| mkvqlwlvksvpozqrnuylmwmvsqosnxml |