Skip to content

Some tests depend on execution order and inherited color environment variables #14690

Description

@Darlokt

Describe the bug

Hej,
I found some Sphinx tests that are flaky because they depend on shared test directories or environment variables inherited from the test runner.

test_missing_reference_conditional_pending_xref shares its source and build directory with Python domain tests. Depending on test order, it can leave generated output that causes test_python_python_use_unqualified_type_names to reuse stale build data.

The status iterator tests force color with FORCE_COLOR=1, but do not clear NO_COLOR or NO_COLOUR. If either variable is set in the environment, NO_COLOR takes precedence and the tests can receive newline-based output
instead of the expected carriage-return output.

How to Reproduce

For the test-order issue, run:

uv run pytest -q --tb=short \
  tests/test_transforms/test_transforms_post_transforms.py::test_missing_reference_conditional_pending_xref \
  tests/test_domains/test_domain_py.py::test_python_python_use_unqualified_type_names

The second test can fail because the existing HTML output is considered up-to-date and is not regenerated.
For the environment-variable issue, run:

NO_COLOR=1 uv run pytest -q --tb=short \
  tests/test_util/test_util_display.py::test_status_iterator_verbosity_0

The test expects output containing \r, but receives output containing \n instead.
NO_COLOUR=1 has the same effect.

Environment Information

Platform:              linux; (Linux-6.18.33.2-microsoft-standard-WSL2-x86_64-with-glibc2.39)
Python version:        3.14.7 (main, Aug 14 2026, 15:35:28) [Clang 22.1.3 ])
Python implementation: CPython
Sphinx version:        9.1.1+/f4bca342e
Docutils version:      0.22.3
Jinja2 version:        3.1.6
Pygments version:      2.19.2

Sphinx extensions

[]

Additional context

The affected tests are:

  • tests/test_transforms/test_transforms_post_transforms.py::test_missing_reference_conditional_pending_xref
  • tests/test_domains/test_domain_py.py::test_python_python_use_unqualified_type_names
  • tests/test_util/test_util_display.py::test_status_iterator_verbosity_0
  • tests/test_util/test_util_display.py::test_status_iterator_verbosity_1

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions