From f2163e6bf8f0700618afc0c11ac885928d619997 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Schoentgen?= Date: Wed, 8 May 2024 18:45:06 +0200 Subject: [PATCH 1/4] fix: Set proper `notfound_urls_prefix` option types --- notfound/extension.py | 1 + tests/examples/conf-urls-prefix-none/conf.py | 11 +++++++++++ tests/examples/conf-urls-prefix-none/index.rst | 10 ++++++++++ tests/test_urls.py | 7 +++++++ 4 files changed, 29 insertions(+) create mode 100644 tests/examples/conf-urls-prefix-none/conf.py create mode 100644 tests/examples/conf-urls-prefix-none/index.rst diff --git a/notfound/extension.py b/notfound/extension.py index b46ccf8..b9cbfa5 100644 --- a/notfound/extension.py +++ b/notfound/extension.py @@ -299,6 +299,7 @@ def setup(app): default_version=default_version, ), 'html', + types=[str, type(None)], ) app.connect('config-inited', validate_configs) diff --git a/tests/examples/conf-urls-prefix-none/conf.py b/tests/examples/conf-urls-prefix-none/conf.py new file mode 100644 index 0000000..1230f91 --- /dev/null +++ b/tests/examples/conf-urls-prefix-none/conf.py @@ -0,0 +1,11 @@ +""" +Sample ``conf.py``. +""" + +master_doc = 'index' + +extensions = [ + 'notfound.extension', +] + +notfound_urls_prefix = None diff --git a/tests/examples/conf-urls-prefix-none/index.rst b/tests/examples/conf-urls-prefix-none/index.rst new file mode 100644 index 0000000..ef421c3 --- /dev/null +++ b/tests/examples/conf-urls-prefix-none/index.rst @@ -0,0 +1,10 @@ +Example page +============ + +This is an example page. + + +.. toctree:: + :glob: + + * diff --git a/tests/test_urls.py b/tests/test_urls.py index beb93e8..dad2193 100644 --- a/tests/test_urls.py +++ b/tests/test_urls.py @@ -40,6 +40,13 @@ def test_parallel_build(): # https://github.com/sphinx-doc/sphinx/pull/8257 subprocess.check_call('sphinx-build -j 2 -W -b html tests/examples/parallel-build build', shell=True) + +@pytest.mark.sphinx(srcdir=srcdir) +def test_notfound_urls_prefix_can_be_none(): + """Note: Sphinx warnings being treated as errors, if the test contains any warning, it will fail then.""" + subprocess.check_call('sphinx-build -W -b html tests/examples/conf-urls-prefix-none build', shell=True) + + @pytest.mark.sphinx(srcdir=srcdir) def test_404_page_created(app, status, warning): app.build() From cc6a30b6d013269da3958d9069382fce8bedb5af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Schoentgen?= Date: Thu, 23 May 2024 16:07:14 +0200 Subject: [PATCH 2/4] feat(tests): Simplify --- tests/examples/conf-urls-prefix-none/conf.py | 11 ----------- tests/examples/conf-urls-prefix-none/index.rst | 10 ---------- tests/test_urls.py | 9 +++------ 3 files changed, 3 insertions(+), 27 deletions(-) delete mode 100644 tests/examples/conf-urls-prefix-none/conf.py delete mode 100644 tests/examples/conf-urls-prefix-none/index.rst diff --git a/tests/examples/conf-urls-prefix-none/conf.py b/tests/examples/conf-urls-prefix-none/conf.py deleted file mode 100644 index 1230f91..0000000 --- a/tests/examples/conf-urls-prefix-none/conf.py +++ /dev/null @@ -1,11 +0,0 @@ -""" -Sample ``conf.py``. -""" - -master_doc = 'index' - -extensions = [ - 'notfound.extension', -] - -notfound_urls_prefix = None diff --git a/tests/examples/conf-urls-prefix-none/index.rst b/tests/examples/conf-urls-prefix-none/index.rst deleted file mode 100644 index ef421c3..0000000 --- a/tests/examples/conf-urls-prefix-none/index.rst +++ /dev/null @@ -1,10 +0,0 @@ -Example page -============ - -This is an example page. - - -.. toctree:: - :glob: - - * diff --git a/tests/test_urls.py b/tests/test_urls.py index c14a81c..01f6a78 100644 --- a/tests/test_urls.py +++ b/tests/test_urls.py @@ -40,12 +40,6 @@ def test_parallel_build(): subprocess.check_call('sphinx-build -j 2 -W -b html tests/examples/parallel-build build', shell=True) -@pytest.mark.sphinx(srcdir=srcdir) -def test_notfound_urls_prefix_can_be_none(): - """Note: Sphinx warnings being treated as errors, if the test contains any warning, it will fail then.""" - subprocess.check_call('sphinx-build -W -b html tests/examples/conf-urls-prefix-none build', shell=True) - - @pytest.mark.sphinx(srcdir=srcdir) def test_404_page_created(app, status, warning): app.build() @@ -203,6 +197,9 @@ def test_urls_prefix_setting_none(app, status, warning): for chunk in chunks: assert chunk in content + assert "The config value `notfound_urls_prefix' has type `NoneType', defaults to `str'" not in warning.getvalue() + assert "build succeeded." in status.getvalue() + @pytest.mark.sphinx( srcdir=srcdir, From 7231e492de8992b7da52ea60124c645344c1b3d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Schoentgen?= Date: Thu, 23 May 2024 16:08:34 +0200 Subject: [PATCH 3/4] chore: restore lines --- tests/test_urls.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/test_urls.py b/tests/test_urls.py index 01f6a78..60a9a77 100644 --- a/tests/test_urls.py +++ b/tests/test_urls.py @@ -159,7 +159,6 @@ def test_urls_prefix_setting(app, status, warning): for chunk in chunks: assert chunk in content - @pytest.mark.sphinx( srcdir=srcdir, confoverrides={ @@ -200,7 +199,6 @@ def test_urls_prefix_setting_none(app, status, warning): assert "The config value `notfound_urls_prefix' has type `NoneType', defaults to `str'" not in warning.getvalue() assert "build succeeded." in status.getvalue() - @pytest.mark.sphinx( srcdir=srcdir, confoverrides={ From df835cb26767968d65d2f55cbd61b646642732e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Schoentgen?= Date: Thu, 23 May 2024 16:09:28 +0200 Subject: [PATCH 4/4] again --- tests/test_urls.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_urls.py b/tests/test_urls.py index 60a9a77..80a2e73 100644 --- a/tests/test_urls.py +++ b/tests/test_urls.py @@ -39,7 +39,6 @@ def test_parallel_build(): # https://github.com/sphinx-doc/sphinx/pull/8257 subprocess.check_call('sphinx-build -j 2 -W -b html tests/examples/parallel-build build', shell=True) - @pytest.mark.sphinx(srcdir=srcdir) def test_404_page_created(app, status, warning): app.build() @@ -159,6 +158,7 @@ def test_urls_prefix_setting(app, status, warning): for chunk in chunks: assert chunk in content + @pytest.mark.sphinx( srcdir=srcdir, confoverrides={