-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Open
Labels
Description
Describe the bug
In trying to reproduce failure with Docutils HEAD with tests/test_builders/test_build_html_numfig.py::test_numfig_disabled_warn at my locale, which I failed to do, I hit against an unrelated testing problem which showed up using pytest directly. I then reproduced using tox:
sphinx$ tox -e py313 -- tests/test_directives/test_directive_code.py::test_literalinclude_namedlink_latex
...
# warning:
WARNING: file PosixPath('/Users/xxx/sphinx/index') given on command line does not exist,
...
=========================== short test summary info ============================
FAILED tests/test_directives/test_directive_code.py::test_literalinclude_namedlink_latex - FileNotFoundError: [Errno 2] No such file or directory: '/private/var/folde...
============================== 1 failed in 0.38s ===============================
But if I launch the whole of test_directive_code.py it succeeds.
sphinx$ tox -e py313 -- tests/test_directives/test_directive_code.py
...
============================== 41 passed in 1.43s ==============================
.pkg: _exit> python /Users/xxx/yyy/zzz/.venv313/lib/python3.13/site-packages/pyproject_api/_backend.py True flit_core.buildapi
py313: OK (2.47=setup[0.54]+cmd[1.94] seconds)
congratulations :) (2.65 seconds)
I had first hit the issue using pytest via make test and then via python -mpytest:
sphinx$ python -m pytest -n logical --dist=worksteal -vv tests
============================= test session starts ==============================
platform darwin -- Python 3.13.3, pytest-8.4.2, pluggy-1.6.0 -- /Users/xxx/yyy/zzz/.venv313/bin/python
cachedir: .pytest_cache
libraries: Sphinx-8.3.0+/e347e59cc, docutils-0.22.3b1.dev
GIL enabled?: True
test roots directory: /Users/xxx/sphinx/tests/roots
base tmp_path: /private/var/folders/yq/77ttbq8142lf9svc1b3bmmx80000gn/T/pytest-of-xxx/pytest-12
rootdir: /Users/xxx/sphinx
configfile: pyproject.toml
plugins: xdist-3.8.0
10 workers [2364 items]
scheduling tests via WorkStealingScheduling
...
FAILED tests/test_directives/test_directive_code.py::test_literalinclude_caption_latex - FileNotFoundError: [Errno 2] No such file or directory: '/private/var/folders/yq/77ttbq8142lf9svc1b3bmmx80000gn/T/pytest-of-xxx/pytest-12/popen-gw4/directive-code/_build/latex/projectnamenotset.tex'
FAILED tests/test_directives/test_directive_code.py::test_literalinclude_namedlink_latex - FileNotFoundError: [Errno 2] No such file or directory: '/private/var/folders/yq/77ttbq8142lf9svc1b3bmmx80000gn/T/pytest-of-xxx/pytest-12/popen-gw4/directive-code/_build/latex/projectnamenotset.tex'
FAILED tests/test_ext_autodoc/test_ext_autodoc_importer.py::test_import_native_module_stubs - ModuleNotFoundError: No module named 'fish_licence.halibut'
=========== 3 failed, 2351 passed, 10 skipped, 11 warnings in 53.62s ===========
I was used to the 'fish_licence.halibut' problem so did not pay attention but the other two were new.
Turns out those two files are the only ones containing '(Path('index')'
sphinx$ grep -r '(Path('\''index'\'')' tests
tests/test_directives/test_directive_code.py: app.build(filenames=(Path('index'),))
tests/test_directives/test_directive_code.py: app.build(filenames=(Path('index'),))
It seems this is not robust against testing using multiple workers.
How to Reproduce
(see above)
Environment Information
Platform: darwin; (macOS-15.6.1-arm64-arm-64bit-Mach-O)
Python version: 3.13.3 (v3.13.3:6280bb54784, Apr 8 2025, 10:47:54) [Clang 15.0.0 (clang-1500.3.9.4)])
Python implementation: CPython
Sphinx version: 8.3.0+/e347e59cc
Docutils version: 0.22.3b1.dev
Jinja2 version: 3.1.6
Pygments version: 2.19.1
Sphinx extensions
Additional context
I have noticed our CI uses Python 3.13.7 and I have not yet tried with it.