Skip to content

1.0.0: pytest fails with sphinx 7.2.x #229

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
kloczek opened this issue Mar 16, 2024 · 3 comments
Closed

1.0.0: pytest fails with sphinx 7.2.x #229

kloczek opened this issue Mar 16, 2024 · 3 comments
Labels
Improvement Minor improvement to code Needed: tests Tests are required

Comments

@kloczek
Copy link
Contributor

kloczek commented Mar 16, 2024

Looks like test suite fails in 6 units

Here is pytest output:
+ PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-sphinx-notfound-page-1.0.0-4.fc36.x86_64/usr/lib64/python3.9/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-sphinx-notfound-page-1.0.0-4.fc36.x86_64/usr/lib/python3.9/site-packages
+ /usr/bin/pytest -ra -m 'not network'
============================= test session starts ==============================
platform linux -- Python 3.9.18, pytest-8.1.1, pluggy-1.4.0
rootdir: /home/tkloczko/rpmbuild/BUILD/sphinx-notfound-page-1.0.0
configfile: pytest.ini
collected 20 items

tests/test_urls.py ..F..FF.F...F.F.....                                  [100%]

=================================== FAILURES ===================================
____________________________ test_default_settings _____________________________

app = <SphinxTestApp buildername='html'>
status = <_io.StringIO object at 0x7f77be8fe280>
warning = <_io.StringIO object at 0x7f77be8fe1f0>

    @pytest.mark.sphinx(srcdir=srcdir)
    def test_default_settings(app, status, warning):
        app.build()
        path = app.outdir / '404.html'
        assert path.exists()
        content = open(path).read()

        if sphinx.version_info < (6, 0):
            cssclass = "shortcut "
        else:
            cssclass = ""

        chunks = [
            '<h1>Page not found</h1>',
            "Unfortunately we couldn't find the content you were looking for.",
            '<title>Page not found &#8212; Python  documentation</title>',

            # favicon and logo
            f'<link rel="{cssclass}icon" href="/en/latest/_static/favicon.png"/>',
            '<img class="logo" src="/en/latest/_static/logo.svg" alt="Logo"/>',

            # sidebar URLs
            '<h1 class="logo"><a href="/en/latest/index.html">Python</a></h1>',
            '<form class="search" action="/en/latest/search.html" method="get">',
            '<li><a href="/en/latest/index.html">Documentation overview</a><ul>',

            # resources
            _get_css_html_link_tag('en', 'latest', 'alabaster.css'),
            _get_css_html_link_tag('en', 'latest', 'pygments.css'),
            '<link rel="stylesheet" href="/en/latest/_static/custom.css" type="text/css" />',
        ]

        for chunk in chunks:
>           assert chunk in content
E           assert '<link rel="stylesheet" type="text/css" href="/en/latest/_static/alabaster.css?v=039e1c02" />' in '<!DOCTYPE html>\n\n<html lang="en" data-content_root="./">\n  <head>\n    <meta charset="utf-8" />\n    <meta name="v...a href="https://alabaster.readthedocs.io">Alabaster 0.7.16</a>\n      \n    </div>\n\n    \n\n    \n  </body>\n</html>'

tests/test_urls.py:83: AssertionError
--------------------------- Captured stdout teardown ---------------------------
# testroot: root
# builder: html
# srcdir: /home/tkloczko/rpmbuild/BUILD/sphinx-notfound-page-1.0.0/tests/examples/default
# outdir: /home/tkloczko/rpmbuild/BUILD/sphinx-notfound-page-1.0.0/tests/examples/default/_build/html
# status:
Running Sphinx v7.2.6
building [mo]: targets for 0 po files that are out of date
writing output...
building [html]: targets for 3 source files that are out of date
updating environment: [new config] 3 added, 0 changed, 0 removed
reading sources... [100%] index
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... [100%] index
generating indices... genindex 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 tests/examples/default/_build/html.

# warning:

___________________________ test_urls_prefix_setting ___________________________

app = <SphinxTestApp buildername='html'>
status = <_io.StringIO object at 0x7f77be821040>
warning = <_io.StringIO object at 0x7f77be7f3af0>

    @pytest.mark.sphinx(
        srcdir=srcdir,
        confoverrides={
            'notfound_urls_prefix': '/language/version/',
        },
    )
    def test_urls_prefix_setting(app, status, warning):
        app.build()
        path = app.outdir / '404.html'
        assert path.exists()

        content = open(path).read()

        if sphinx.version_info < (6, 0):
            cssclass = "shortcut "
        else:
            cssclass = ""

        chunks = [
            # sidebar URLs
            '<h1 class="logo"><a href="/language/version/index.html">Python</a></h1>',
            '<form class="search" action="/language/version/search.html" method="get">',
            '<li><a href="/language/version/index.html">Documentation overview</a><ul>',

            # favicon and logo
            f'<link rel="{cssclass}icon" href="/language/version/_static/favicon.png"/>',
            '<img class="logo" src="/language/version/_static/logo.svg" alt="Logo"/>',

            # resources
            _get_css_html_link_tag('language', 'version', 'alabaster.css'),
            _get_css_html_link_tag('language', 'version', 'pygments.css'),
            '<link rel="stylesheet" href="/language/version/_static/custom.css" type="text/css" />',
        ]

        for chunk in chunks:
>           assert chunk in content
E           assert '<link rel="stylesheet" type="text/css" href="/language/version/_static/alabaster.css?v=039e1c02" />' in '<!DOCTYPE html>\n\n<html lang="en" data-content_root="./">\n  <head>\n    <meta charset="utf-8" />\n    <meta name="v...a href="https://alabaster.readthedocs.io">Alabaster 0.7.16</a>\n      \n    </div>\n\n    \n\n    \n  </body>\n</html>'

tests/test_urls.py:154: AssertionError
--------------------------- Captured stdout teardown ---------------------------
# testroot: root
# builder: html
# srcdir: /home/tkloczko/rpmbuild/BUILD/sphinx-notfound-page-1.0.0/tests/examples/default
# outdir: /home/tkloczko/rpmbuild/BUILD/sphinx-notfound-page-1.0.0/tests/examples/default/_build/html
# status:
Running Sphinx v7.2.6
building [mo]: targets for 0 po files that are out of date
writing output...
building [html]: targets for 3 source files that are out of date
updating environment: [new config] 3 added, 0 changed, 0 removed
reading sources... [100%] index
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... [100%] index
generating indices... genindex 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 tests/examples/default/_build/html.

# warning:

________________________ test_urls_prefix_setting_none _________________________

app = <SphinxTestApp buildername='html'>
status = <_io.StringIO object at 0x7f77be772430>
warning = <_io.StringIO object at 0x7f77be772040>

    @pytest.mark.sphinx(
        srcdir=srcdir,
        confoverrides={
            'notfound_urls_prefix': None,
        },
    )
    def test_urls_prefix_setting_none(app, status, warning):
        app.build()
        path = app.outdir / '404.html'
        assert path.exists()

        content = open(path).read()

        if sphinx.version_info < (6, 0):
            cssclass = "shortcut "
        else:
            cssclass = ""

        chunks = [
            # sidebar URLs
            '<h1 class="logo"><a href="/index.html">Python</a></h1>',
            '<form class="search" action="/search.html" method="get">',
            '<li><a href="/index.html">Documentation overview</a><ul>',

            # favicon and logo
            f'<link rel="{cssclass}icon" href="/_static/favicon.png"/>',
            '<img class="logo" src="/_static/logo.svg" alt="Logo"/>',

            # resources
            _get_css_html_link_tag('', '', 'alabaster.css'),
            _get_css_html_link_tag('', '', 'pygments.css'),
            '<link rel="stylesheet" href="/_static/custom.css" type="text/css" />',
        ]

        for chunk in chunks:
>           assert chunk in content
E           assert '<link rel="stylesheet" type="text/css" href="/_static/alabaster.css?v=039e1c02" />' in '<!DOCTYPE html>\n\n<html lang="en" data-content_root="./">\n  <head>\n    <meta charset="utf-8" />\n    <meta name="v...a href="https://alabaster.readthedocs.io">Alabaster 0.7.16</a>\n      \n    </div>\n\n    \n\n    \n  </body>\n</html>'

tests/test_urls.py:192: AssertionError
--------------------------- Captured stdout teardown ---------------------------
# testroot: root
# builder: html
# srcdir: /home/tkloczko/rpmbuild/BUILD/sphinx-notfound-page-1.0.0/tests/examples/default
# outdir: /home/tkloczko/rpmbuild/BUILD/sphinx-notfound-page-1.0.0/tests/examples/default/_build/html
# status:
Running Sphinx v7.2.6
building [mo]: targets for 0 po files that are out of date
writing output...
building [html]: targets for 3 source files that are out of date
updating environment: [new config] 3 added, 0 changed, 0 removed
reading sources... [100%] index
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... [100%] index
generating indices... genindex done
writing additional pages... search done
dumping search index in English (code: en)... done
dumping object inventory... done
build succeeded, 1 warning.

The HTML pages are in tests/examples/default/_build/html.

# warning:
WARNING: The config value `notfound_urls_prefix' has type `NoneType', defaults to `str'.

__________________________ test_custom_404_rst_source __________________________

app = <SphinxTestApp buildername='html'>
status = <_io.StringIO object at 0x7f77be643e50>
warning = <_io.StringIO object at 0x7f77be643dc0>

    @pytest.mark.sphinx(
        srcdir=rstsrcdir,
        confoverrides={
            'version': '2.5.1',
        },
    )
    def test_custom_404_rst_source(app, status, warning):
        app.build()
        path = app.outdir / '404.html'
        assert path.exists()

        content = open(path).read()

        chunks = [
            # custom 404.rst file content
            '<title>Oh, oh - Page not found &#8212; Python  documentation</title>',
            '<p>This is a custom 404.rst file.</p>',
            '<p>This file should be rendered instead of the default one.</p>',
            "<p>Variables Sphinx substitution should be allowed here.\nExample, version: 2.5.1.</p>",

            # sidebar URLs
            '<h1 class="logo"><a href="/en/latest/index.html">Python</a></h1>',
            '<form class="search" action="/en/latest/search.html" method="get">',
            '<li><a href="/en/latest/index.html">Documentation overview</a><ul>',

            # resources
            _get_css_html_link_tag('en', 'latest', 'alabaster.css'),
            _get_css_html_link_tag('en', 'latest', 'pygments.css'),
            '<link rel="stylesheet" href="/en/latest/_static/custom.css" type="text/css" />',
        ]

        for chunk in chunks:
>           assert chunk in content
E           assert '<link rel="stylesheet" type="text/css" href="/en/latest/_static/alabaster.css?v=039e1c02" />' in '<!DOCTYPE html>\n\n<html lang="en" data-content_root="./">\n  <head>\n    <meta charset="utf-8" />\n    <meta name="v...latest/_sources/404.rst.txt"\n          rel="nofollow">Page source</a>\n    </div>\n\n    \n\n    \n  </body>\n</html>'

tests/test_urls.py:256: AssertionError
--------------------------- Captured stdout teardown ---------------------------
# testroot: root
# builder: html
# srcdir: /home/tkloczko/rpmbuild/BUILD/sphinx-notfound-page-1.0.0/tests/examples/404rst
# outdir: /home/tkloczko/rpmbuild/BUILD/sphinx-notfound-page-1.0.0/tests/examples/404rst/_build/html
# status:
Running Sphinx v7.2.6
building [mo]: targets for 0 po files that are out of date
writing output...
building [html]: targets for 2 source files that are out of date
updating environment: [new config] 2 added, 0 changed, 0 removed
reading sources... [100%] index
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... [100%] index
generating indices... genindex done
writing additional pages... search done
copying images... [100%] https.png
dumping search index in English (code: en)... done
dumping object inventory... done
build succeeded.

The HTML pages are in tests/examples/404rst/_build/html.

# warning:

________________________ test_urls_for_dirhtml_builder _________________________

app = <SphinxTestApp buildername='dirhtml'>
status = <_io.StringIO object at 0x7f77bfb40e50>
warning = <_io.StringIO object at 0x7f77bfb409d0>

    @pytest.mark.sphinx(
        srcdir=srcdir,
        buildername='dirhtml',
    )
    def test_urls_for_dirhtml_builder(app, status, warning):
        app.build()
        path = app.outdir / '404' / 'index.html'
        assert path.exists()

        content = open(path).read()

        chunks = [
            # sidebar URLs
            '<form class="search" action="/en/latest/search/" method="get">',
            '<li class="toctree-l1"><a class="reference internal" href="/en/latest/chapter/">Chapter</a></li>',

            # resources
            _get_css_html_link_tag('en', 'latest', 'alabaster.css'),
            _get_css_html_link_tag('en', 'latest', 'pygments.css'),
            '<link rel="stylesheet" href="/en/latest/_static/custom.css" type="text/css" />',
        ]

        for chunk in chunks:
>           assert chunk in content
E           assert '<link rel="stylesheet" type="text/css" href="/en/latest/_static/alabaster.css?v=039e1c02" />' in '<!DOCTYPE html>\n\n<html lang="en" data-content_root="../">\n  <head>\n    <meta charset="utf-8" />\n    <meta name="...a href="https://alabaster.readthedocs.io">Alabaster 0.7.16</a>\n      \n    </div>\n\n    \n\n    \n  </body>\n</html>'

tests/test_urls.py:359: AssertionError
--------------------------- Captured stdout teardown ---------------------------
# testroot: root
# builder: dirhtml
# srcdir: /home/tkloczko/rpmbuild/BUILD/sphinx-notfound-page-1.0.0/tests/examples/default
# outdir: /home/tkloczko/rpmbuild/BUILD/sphinx-notfound-page-1.0.0/tests/examples/default/_build/dirhtml
# status:
Running Sphinx v7.2.6
building [mo]: targets for 0 po files that are out of date
writing output...
building [dirhtml]: targets for 3 source files that are out of date
updating environment: [new config] 3 added, 0 changed, 0 removed
reading sources... [100%] index
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... [100%] index
generating indices... genindex 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 tests/examples/default/_build/dirhtml.

# warning:

______________________ test_toctree_urls_notfound_default ______________________

app = <SphinxTestApp buildername='html'>
status = <_io.StringIO object at 0x7f77be9114c0>
warning = <_io.StringIO object at 0x7f77be911160>

    @pytest.mark.sphinx(
        srcdir=srcdir,
        confoverrides={
            'notfound_urls_prefix': '/ja/default/',
        },
    )
    def test_toctree_urls_notfound_default(app, status, warning):
        app.build()
        path = app.outdir / '404.html'
        assert path.exists()

        content = open(path).read()

        chunks = [
            # sidebar URLs
            '<form class="search" action="/ja/default/search.html" method="get">',
            '<li class="toctree-l1"><a class="reference internal" href="/ja/default/chapter.html">Chapter</a></li>',

            # resources
            _get_css_html_link_tag('ja', 'default', 'alabaster.css'),
            _get_css_html_link_tag('ja', 'default', 'pygments.css'),
            '<link rel="stylesheet" href="/ja/default/_static/custom.css" type="text/css" />',
        ]

        for chunk in chunks:
>           assert chunk in content
E           assert '<link rel="stylesheet" type="text/css" href="/ja/default/_static/alabaster.css?v=039e1c02" />' in '<!DOCTYPE html>\n\n<html lang="en" data-content_root="./">\n  <head>\n    <meta charset="utf-8" />\n    <meta name="v...a href="https://alabaster.readthedocs.io">Alabaster 0.7.16</a>\n      \n    </div>\n\n    \n\n    \n  </body>\n</html>'

tests/test_urls.py:410: AssertionError
--------------------------- Captured stdout teardown ---------------------------
# testroot: root
# builder: html
# srcdir: /home/tkloczko/rpmbuild/BUILD/sphinx-notfound-page-1.0.0/tests/examples/default
# outdir: /home/tkloczko/rpmbuild/BUILD/sphinx-notfound-page-1.0.0/tests/examples/default/_build/html
# status:
Running Sphinx v7.2.6
building [mo]: targets for 0 po files that are out of date
writing output...
building [html]: targets for 3 source files that are out of date
updating environment: [new config] 3 added, 0 changed, 0 removed
reading sources... [100%] index
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... [100%] index
generating indices... genindex 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 tests/examples/default/_build/html.

# warning:

=========================== short test summary info ============================
FAILED tests/test_urls.py::test_default_settings - assert '<link rel="stylesh...
FAILED tests/test_urls.py::test_urls_prefix_setting - assert '<link rel="styl...
FAILED tests/test_urls.py::test_urls_prefix_setting_none - assert '<link rel=...
FAILED tests/test_urls.py::test_custom_404_rst_source - assert '<link rel="st...
FAILED tests/test_urls.py::test_urls_for_dirhtml_builder - assert '<link rel=...
FAILED tests/test_urls.py::test_toctree_urls_notfound_default - assert '<link...
========================= 6 failed, 14 passed in 4.74s =========================
@humitos humitos added Improvement Minor improvement to code Needed: tests Tests are required labels Mar 18, 2024
@kloczek
Copy link
Contributor Author

kloczek commented May 21, 2024

Looks like 1.0.1 solved the issue

+ PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-sphinx-notfound-page-1.0.1-2.fc37.x86_64/usr/lib64/python3.10/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-sphinx-notfound-page-1.0.1-2.fc37.x86_64/usr/lib/python3.10/site-packages
+ /usr/bin/pytest -ra -m 'not network'
==================================================================================== test session starts ====================================================================================
platform linux -- Python 3.10.14, pytest-8.1.1, pluggy-1.4.0
rootdir: /home/tkloczko/rpmbuild/BUILD/sphinx-notfound-page-1.0.1
configfile: pytest.ini
plugins: anyio-4.3.0, forked-1.6.0, localserver-0.8.1, asyncio-0.23.7
asyncio: mode=strict
collected 21 items

tests/test_urls.py .....................                                                                                                                                              [100%]

===================================================================================== warnings summary ======================================================================================
tests/test_urls.py: 80 warnings
  /home/tkloczko/rpmbuild/BUILD/sphinx-notfound-page-1.0.1/notfound/extension.py:269: RemovedInSphinx90Warning: The '_Opt' object tuple interface is deprecated, use attribute access instead for 'default', 'rebuild', and 'valid_types'.
    default, rebuild, types = app.config.values.get('notfound_urls_prefix')

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
============================================================================== 21 passed, 80 warnings in 5.37s ==============================================================================

Only remaining thing is pytest warning.

@humitos
Copy link
Member

humitos commented May 21, 2024

Only remaining thing is pytest warning.

Tracked in #234

@humitos
Copy link
Member

humitos commented Aug 27, 2024

It seems this is already solved.

@humitos humitos closed this as not planned Won't fix, can't repro, duplicate, stale Aug 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Improvement Minor improvement to code Needed: tests Tests are required
Projects
None yet
Development

No branches or pull requests

2 participants