python-trio / sphinxcontrib-trio

Make Sphinx better at documenting Python functions and methods
Other
25 stars 11 forks source link

1.1.2: pytest fails in one unit #398

Open kloczek opened 10 months ago

kloczek commented 10 months ago

I'm packaging your module as an rpm package so I'm using the typical PEP517 based build, install and test cycle used on building packages from non-root account.

Here is pytest output: ```console + PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-sphinxcontrib-trio-1.1.2-15.fc35.x86_64/usr/lib64/python3.8/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-sphinxcontrib-trio-1.1.2-15.fc35.x86_64/usr/lib/python3.8/site-packages + /usr/bin/pytest -ra -m 'not network' ==================================================================================== test session starts ==================================================================================== platform linux -- Python 3.8.18, pytest-7.4.4, pluggy-1.3.0 rootdir: /home/tkloczko/rpmbuild/BUILD/sphinxcontrib-trio-1.1.2 plugins: datadir-1.5.0, regressions-2.5.0 collected 3 items tests/test_sphinxcontrib_trio.py .F. [100%] ========================================================================================= FAILURES ========================================================================================== ______________________________________________________________________________________ test_end_to_end ______________________________________________________________________________________ tmpdir = local('/tmp/pytest-of-tkloczko/pytest-69/test_end_to_end0') def test_end_to_end(tmpdir): shutil.copytree(str(Path(__file__).parent / "test-docs-source"), str(tmpdir / "test-docs-source")) subprocess.run( ["sphinx-build", "-v", "-nW", "-nb", "html", str(tmpdir / "test-docs-source"), str(tmpdir / "out")]) tree = lxml.html.parse(str(tmpdir / "out" / "test.html")).getroot() def do_html_test(node, *, expect_match): original_content = node.text_content() print("\n-- test case --\n", lxml.html.tostring(node, encoding="unicode")) check_tags = node.cssselect(".highlight-none") checks = [] for tag in check_tags: text = tag.text_content().strip() # lxml normalizes   to the unicode \xa0, so we do the same text = text.replace(" ", "\xa0") checks.append(text) tag.drop_tree() # make sure we removed the tests from the top-level node, to avoid # potential false positives matching on the tests themselves! assert len(node.text_content()) < len(original_content) assert checks test_content = lxml.html.tostring(node, encoding="unicode") # some versions of sphinx (>= 1.6) replace "..." with the ellipsis # character \u2026. Normalize back to "..." for comparison # purposes. test_content = test_content.replace("\u2026", "...") for check in checks: try: if expect_match: assert re.search(check, test_content) is not None else: assert re.search(check, test_content) is None except AssertionError: print("failed check") print() print(repr(check)) print() print("failed test_content") print() print(repr(test_content)) raise print("\n-- NEGATIVE (WARNING) TESTS --\n") for warning in tree.cssselect(".warning"): do_html_test(warning, expect_match=False) print("\n-- POSITIVE (NOTE) TESTS --\n") for note in tree.cssselect(".note"): > do_html_test(note, expect_match=True) tests/test_sphinxcontrib_trio.py:241: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ node = def do_html_test(node, *, expect_match): original_content = node.text_content() print("\n-- test case --\n", lxml.html.tostring(node, encoding="unicode")) check_tags = node.cssselect(".highlight-none") checks = [] for tag in check_tags: text = tag.text_content().strip() # lxml normalizes   to the unicode \xa0, so we do the same text = text.replace(" ", "\xa0") checks.append(text) tag.drop_tree() # make sure we removed the tests from the top-level node, to avoid # potential false positives matching on the tests themselves! assert len(node.text_content()) < len(original_content) assert checks test_content = lxml.html.tostring(node, encoding="unicode") # some versions of sphinx (>= 1.6) replace "..." with the ellipsis # character \u2026. Normalize back to "..." for comparison # purposes. test_content = test_content.replace("\u2026", "...") for check in checks: try: if expect_match: > assert re.search(check, test_content) is not None E assert None is not None E + where None = ('await foo', '
\n

Note

\n
\n
bar)
\n
\n\n\n
\n') E + where = re.search tests/test_sphinxcontrib_trio.py:220: AssertionError ----------------------------------------------------------------------------------- Captured stdout call ------------------------------------------------------------------------------------ Running Sphinx v7.1.2 making output directory... done locale_dir /tmp/pytest-of-tkloczko/pytest-69/test_end_to_end0/test-docs-source/locales/en/LC_MESSAGES does not exists [autosummary] generating autosummary for: test.rst [autosummary] generating autosummary for: /tmp/pytest-of-tkloczko/pytest-69/test_end_to_end0/test-docs-source/autodoc_examples.autosummary_me.rst locale_dir /tmp/pytest-of-tkloczko/pytest-69/test_end_to_end0/test-docs-source/locales/en/LC_MESSAGES does not exists building [mo]: targets for 0 po files that are out of date writing output... building [html]: targets for 1 source files that are out of date updating environment: locale_dir /tmp/pytest-of-tkloczko/pytest-69/test_end_to_end0/test-docs-source/locales/en/LC_MESSAGES does not exists [new config] 2 added, 0 changed, 0 removed reading sources... [ 50%] autodoc_examples.autosummary_me reading sources... [100%] test 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 done writing output... [ 50%] autodoc_examples.autosummary_me writing output... [100%] test generating indices... genindex py-modindex done writing additional pages... search done dumping search index in English (code: en)... done dumping object inventory... done build succeeded. The HTML pages are in ../../../../../tmp/pytest-of-tkloczko/pytest-69/test_end_to_end0/out. -- NEGATIVE (WARNING) TESTS -- -- test case --

Warning

foo(bar)
<em class="property">await </em><code class="(sig-name )?descname">foo</code>
-- test case --

Warning

autodoc_examples.basic()
</em><code class="(sig-name )?descname">basic</code>
-- test case --

Warning

class autodoc_examples.ExampleInheritedSubclass
a_syncmethod()
b_syncmethod()
await c_asyncmethod()
await d_asyncmethod()
<em class="property">await </em><code class="(sig-name )?descname">a_syncmethod</code>
<em class="property">await </em><code class="(sig-name )?descname">b_syncmethod</code>
-- test case --

Warning

autodoc_examples.gen()
for
-- POSITIVE (NOTE) TESTS -- -- test case --

Note

await foo(bar)
<em class="property">await </em><code class="(sig-name )?descname">foo</code>
failed check 'await foo' failed test_content '
\n

Note

\n
\n
\nawait foo(bar)
\n
\n\n\n
\n' ================================================================================== short test summary info ================================================================================== FAILED tests/test_sphinxcontrib_trio.py::test_end_to_end - assert None is not None ================================================================================ 1 failed, 2 passed in 2.51s ================================================================================ ```
List of installed modules in build env: ```console Package Version ----------------------------- ------- alabaster 0.7.16 Babel 2.14.0 build 1.0.3 charset-normalizer 3.3.2 cppclean 0.13 cssselect 1.2.0 distro 1.9.0 dnf 4.18.2 docutils 0.20.1 exceptiongroup 1.1.3 gpg 1.23.2 idna 3.6 imagesize 1.4.1 importlib-metadata 7.0.1 iniconfig 2.0.0 installer 0.7.0 Jinja2 3.1.3 libdnf 0.72.0 lxml 5.0.0 MarkupSafe 2.1.3 packaging 23.2 pluggy 1.3.0 Pygments 2.17.2 pyproject_hooks 1.0.0 pytest 7.4.4 python-dateutil 2.8.2 pytz 2023.3 requests 2.31.0 setuptools 69.0.3 six 1.16.0 snowballstemmer 2.2.0 Sphinx 7.1.2 sphinxcontrib-applehelp 1.0.4 sphinxcontrib-devhelp 1.0.5 sphinxcontrib-htmlhelp 2.0.5 sphinxcontrib-jsmath 1.0.1 sphinxcontrib-qthelp 1.0.7 sphinxcontrib-serializinghtml 1.1.10 tomli 2.0.1 urllib3 1.26.18 wheel 0.42.0 zipp 3.17.0 ```

Please let me know if you need more details or want me to perform some diagnostics.

thmo commented 1 month ago

Duplicate of #260, I think.