sphinx-doc / sphinx-argparse

A Sphinx extension to automatically document argparse commands and options
https://sphinx-argparse.readthedocs.org/
MIT License
32 stars 25 forks source link

`test/test_default_html.py::test_default_html` fails in 0.5.0 #59

Closed mgorny closed 4 months ago

mgorny commented 4 months ago
$ pip install -q -e '.[test]'
$ pytest
========================================================= test session starts =========================================================
platform linux -- Python 3.12.4, pytest-8.2.2, pluggy-1.5.0
rootdir: /tmp/sphinx-argparse
configfile: pyproject.toml
plugins: deadfixtures-2.2.1
collected 19 items                                                                                                                    

test/test_default_html.py FF..                                                                                                  [ 21%]
test/test_parser.py ...............                                                                                             [100%]

============================================================== FAILURES ===============================================================
_____________________________________________ test_default_html[index.html-expect_list0] ______________________________________________
test/test_default_html.py:105: in test_default_html
    check_xpath(cached_etree_parse(app.outdir / fname), fname, *expect)
test/test_default_html.py:14: in check_xpath
    assert nodes != [], f'did not find any node matching xpath {path!r} in file {fname}'
E   AssertionError: did not find any node matching xpath ".//section[@id='positional-arguments']" in file index.html
E   assert [] != []
-------------------------------------------------------- Captured stdout call ---------------------------------------------------------
/tmp/pytest-of-mgorny/pytest-2/default-html/_build/html/index.html
------------------------------------------------------ Captured stdout teardown -------------------------------------------------------
# testroot: root
# builder: html
# srcdir: /tmp/pytest-of-mgorny/pytest-2/default-html
# outdir: /tmp/pytest-of-mgorny/pytest-2/default-html/_build/html
# status: 
Running Sphinx v7.4.4
loading translations [en]... done
building [mo]: targets for 0 po files that are out of date
writing output... 
building [html]: targets for 4 source files that are out of date
updating environment: [new config] 4 added, 0 changed, 0 removed
reading sources... [ 25%] default-suppressed
reading sources... [ 50%] index
reading sources... [ 75%] special-characters
reading sources... [100%] subcommand-a

looking for now-outdated files... none found
pickling environment... done
checking consistency... done
preparing documents... done
copying assets... 
copying static files... done
copying extra files... done
copying assets: done
writing output... [ 25%] default-suppressed
writing output... [ 50%] index
writing output... [ 75%] special-characters
writing output... [100%] subcommand-a

generating indices... genindex done
writing additional pages... search done
dumping search index in English (code: en)... done
dumping object inventory... done
build succeeded, 3 warnings.

The HTML pages are in ../pytest-of-mgorny/pytest-2/default-html/_build/html.

# warning: 
/tmp/pytest-of-mgorny/pytest-2/default-html/default-suppressed.rst: WARNING: document isn't included in any toctree
/tmp/pytest-of-mgorny/pytest-2/default-html/special-characters.rst: WARNING: document isn't included in any toctree
/tmp/pytest-of-mgorny/pytest-2/default-html/subcommand-a.rst: WARNING: document isn't included in any toctree

__________________________________________ test_default_html[subcommand-a.html-expect_list1] __________________________________________
test/test_default_html.py:105: in test_default_html
    check_xpath(cached_etree_parse(app.outdir / fname), fname, *expect)
test/test_default_html.py:14: in check_xpath
    assert nodes != [], f'did not find any node matching xpath {path!r} in file {fname}'
E   AssertionError: did not find any node matching xpath ".//section[@id='positional-arguments']" in file subcommand-a.html
E   assert [] != []
-------------------------------------------------------- Captured stdout call ---------------------------------------------------------
/tmp/pytest-of-mgorny/pytest-2/default-html/_build/html/subcommand-a.html
------------------------------------------------------ Captured stdout teardown -------------------------------------------------------
# testroot: root
# builder: html
# srcdir: /tmp/pytest-of-mgorny/pytest-2/default-html
# outdir: /tmp/pytest-of-mgorny/pytest-2/default-html/_build/html
# status: 
Running Sphinx v7.4.4
loading translations [en]... done
loading pickled environment... done
building [mo]: targets for 0 po files that are out of date
writing output... 
building [html]: targets for 0 source files that are out of date
updating environment: 0 added, 0 changed, 0 removed
reading sources... 
looking for now-outdated files... none found
no targets are out of date.
build succeeded.

The HTML pages are in ../pytest-of-mgorny/pytest-2/default-html/_build/html.

# warning: 

======================================================= short test summary info =======================================================
FAILED test/test_default_html.py::test_default_html[index.html-expect_list0] - AssertionError: did not find any node matching xpath ".//section[@id='positional-arguments']" in file index.html
FAILED test/test_default_html.py::test_default_html[subcommand-a.html-expect_list1] - AssertionError: did not find any node matching xpath ".//section[@id='positional-arguments']" in file subcommand-a.html
==================================================== 2 failed, 17 passed in 0.49s =====================================================

The regression seems to have been introduced in 1fd304781364f2edf54f2c012743d5e1e38a14c6.

FWICS, the CI job doesn't run any tests:

Run python -m pytest -vv --dead-fixtures --dup-fixtures --cov . --cov-append --cov-config pyproject.toml

Cool, every declared fixture is being used.

no tests ran in 0.10s

From https://github.com/sphinx-doc/sphinx-argparse/actions/runs/9942352089/job/27463585673. It seems to be caused by the --dead-fixtures option.

AA-Turner commented 4 months ago

FWICS, the CI job doesn't run any tests:

Odd, thank you for pointing it out.

AA-Turner commented 4 months ago

Tests now run in CI (bbd9e5e6c0741908b25971e00bd0b04bd0c9c1b1) and are fixed (f7f767ffd778746d35ac421fe565175784c2e8d6).

A

mgorny commented 4 months ago

Thanks!