mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
[tests] correctly intercept or suppress warnings in tests (#12085)
This commit is contained in:
parent
d6f49f9c09
commit
dbb4da375f
@ -225,6 +225,8 @@ empty_parameter_set_mark = "xfail"
|
|||||||
filterwarnings = [
|
filterwarnings = [
|
||||||
"all",
|
"all",
|
||||||
"ignore::DeprecationWarning:docutils.io",
|
"ignore::DeprecationWarning:docutils.io",
|
||||||
|
"ignore:Distutils was imported before Setuptools:UserWarning:_distutils_hack",
|
||||||
|
"ignore:Setuptools is replacing distutils:UserWarning:_distutils_hack",
|
||||||
"ignore::DeprecationWarning:pyximport.pyximport",
|
"ignore::DeprecationWarning:pyximport.pyximport",
|
||||||
"ignore::ImportWarning:importlib._bootstrap",
|
"ignore::ImportWarning:importlib._bootstrap",
|
||||||
]
|
]
|
||||||
|
@ -6,6 +6,7 @@ import re
|
|||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from sphinx.builders.html import validate_html_extra_path, validate_html_static_path
|
from sphinx.builders.html import validate_html_extra_path, validate_html_static_path
|
||||||
|
from sphinx.deprecation import RemovedInSphinx80Warning
|
||||||
from sphinx.errors import ConfigError
|
from sphinx.errors import ConfigError
|
||||||
from sphinx.util.inventory import InventoryFile
|
from sphinx.util.inventory import InventoryFile
|
||||||
|
|
||||||
@ -341,6 +342,7 @@ def test_validate_html_extra_path(app):
|
|||||||
app.outdir, # outdir
|
app.outdir, # outdir
|
||||||
app.outdir / '_static', # inside outdir
|
app.outdir / '_static', # inside outdir
|
||||||
]
|
]
|
||||||
|
with pytest.warns(RemovedInSphinx80Warning, match='Use "pathlib.Path" or "os.fspath" instead'):
|
||||||
validate_html_extra_path(app, app.config)
|
validate_html_extra_path(app, app.config)
|
||||||
assert app.config.html_extra_path == ['_static']
|
assert app.config.html_extra_path == ['_static']
|
||||||
|
|
||||||
@ -354,6 +356,7 @@ def test_validate_html_static_path(app):
|
|||||||
app.outdir, # outdir
|
app.outdir, # outdir
|
||||||
app.outdir / '_static', # inside outdir
|
app.outdir / '_static', # inside outdir
|
||||||
]
|
]
|
||||||
|
with pytest.warns(RemovedInSphinx80Warning, match='Use "pathlib.Path" or "os.fspath" instead'):
|
||||||
validate_html_static_path(app, app.config)
|
validate_html_static_path(app, app.config)
|
||||||
assert app.config.html_static_path == ['_static']
|
assert app.config.html_static_path == ['_static']
|
||||||
|
|
||||||
|
@ -24,6 +24,7 @@ from sphinx.builders.linkcheck import (
|
|||||||
HyperlinkAvailabilityCheckWorker,
|
HyperlinkAvailabilityCheckWorker,
|
||||||
RateLimit,
|
RateLimit,
|
||||||
)
|
)
|
||||||
|
from sphinx.deprecation import RemovedInSphinx80Warning
|
||||||
from sphinx.testing.util import strip_escseq
|
from sphinx.testing.util import strip_escseq
|
||||||
from sphinx.util import requests
|
from sphinx.util import requests
|
||||||
|
|
||||||
@ -413,7 +414,10 @@ def test_unauthorized_broken(app):
|
|||||||
'linkcheck', testroot='linkcheck-localserver', freshenv=True,
|
'linkcheck', testroot='linkcheck-localserver', freshenv=True,
|
||||||
confoverrides={'linkcheck_auth': [(r'^$', ('user1', 'password'))]})
|
confoverrides={'linkcheck_auth': [(r'^$', ('user1', 'password'))]})
|
||||||
def test_auth_header_no_match(app):
|
def test_auth_header_no_match(app):
|
||||||
with http_server(custom_handler(valid_credentials=("user1", "password"))):
|
with (
|
||||||
|
http_server(custom_handler(valid_credentials=("user1", "password"))),
|
||||||
|
pytest.warns(RemovedInSphinx80Warning, match='linkcheck builder encountered an HTTP 401'),
|
||||||
|
):
|
||||||
app.build()
|
app.build()
|
||||||
|
|
||||||
with open(app.outdir / "output.json", encoding="utf-8") as fp:
|
with open(app.outdir / "output.json", encoding="utf-8") as fp:
|
||||||
|
Loading…
Reference in New Issue
Block a user