mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Fix PT006 (use tuples in `pytest.mark.parametrize
`)
This commit is contained in:
parent
976dd07ffe
commit
02e011e4ff
@ -223,7 +223,6 @@ ignore = [
|
|||||||
"PLW2901", # outer loop variable overwritten by inner assignment
|
"PLW2901", # outer loop variable overwritten by inner assignment
|
||||||
# flake8-pytest-style
|
# flake8-pytest-style
|
||||||
"PT003", # `scope='function'` is implied in `@pytest.fixture()`
|
"PT003", # `scope='function'` is implied in `@pytest.fixture()`
|
||||||
"PT006", # wrong name type in `@pytest.mark.parametrize`,
|
|
||||||
"PT007", # wrong values type in `@pytest.mark.parametrize`
|
"PT007", # wrong values type in `@pytest.mark.parametrize`
|
||||||
"PT011", # `pytest.raises(ValueError)` is too broad, set the `match` parameter
|
"PT011", # `pytest.raises(ValueError)` is too broad, set the `match` parameter
|
||||||
# flake8-use-pathlib
|
# flake8-use-pathlib
|
||||||
|
@ -137,7 +137,7 @@ def test_html4_error(make_app, tmp_path):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("fname,expect", flat_dict({
|
@pytest.mark.parametrize(("fname", "expect"), flat_dict({
|
||||||
'images.html': [
|
'images.html': [
|
||||||
(".//img[@src='_images/img.png']", ''),
|
(".//img[@src='_images/img.png']", ''),
|
||||||
(".//img[@src='_images/img1.png']", ''),
|
(".//img[@src='_images/img1.png']", ''),
|
||||||
@ -406,7 +406,7 @@ def test_html5_output(app, cached_etree_parse, fname, expect):
|
|||||||
check_xpath(cached_etree_parse(app.outdir / fname), fname, *expect)
|
check_xpath(cached_etree_parse(app.outdir / fname), fname, *expect)
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("fname,expect", flat_dict({
|
@pytest.mark.parametrize(("fname", "expect"), flat_dict({
|
||||||
'index.html': [
|
'index.html': [
|
||||||
(".//div[@class='citation']/span", r'Ref1'),
|
(".//div[@class='citation']/span", r'Ref1'),
|
||||||
(".//div[@class='citation']/span", r'Ref_1'),
|
(".//div[@class='citation']/span", r'Ref_1'),
|
||||||
@ -506,7 +506,7 @@ def test_html_translator(app):
|
|||||||
assert app.builder.docwriter.visitor.depart_with_node == 10
|
assert app.builder.docwriter.visitor.depart_with_node == 10
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("fname,expect", flat_dict({
|
@pytest.mark.parametrize(("fname", "expect"), flat_dict({
|
||||||
'index.html': [
|
'index.html': [
|
||||||
(".//li[@class='toctree-l3']/a", '1.1.1. Foo A1', True),
|
(".//li[@class='toctree-l3']/a", '1.1.1. Foo A1', True),
|
||||||
(".//li[@class='toctree-l3']/a", '1.2.1. Foo B1', True),
|
(".//li[@class='toctree-l3']/a", '1.2.1. Foo B1', True),
|
||||||
@ -558,7 +558,7 @@ def test_tocdepth(app, cached_etree_parse, fname, expect):
|
|||||||
check_xpath(cached_etree_parse(app.outdir / fname), fname, *expect)
|
check_xpath(cached_etree_parse(app.outdir / fname), fname, *expect)
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("fname,expect", flat_dict({
|
@pytest.mark.parametrize(("fname", "expect"), flat_dict({
|
||||||
'index.html': [
|
'index.html': [
|
||||||
(".//li[@class='toctree-l3']/a", '1.1.1. Foo A1', True),
|
(".//li[@class='toctree-l3']/a", '1.1.1. Foo A1', True),
|
||||||
(".//li[@class='toctree-l3']/a", '1.2.1. Foo B1', True),
|
(".//li[@class='toctree-l3']/a", '1.2.1. Foo B1', True),
|
||||||
@ -612,7 +612,7 @@ def test_numfig_disabled_warn(app, warning):
|
|||||||
assert 'index.rst:57: WARNING: invalid numfig_format: Fig %s %s' not in warnings
|
assert 'index.rst:57: WARNING: invalid numfig_format: Fig %s %s' not in warnings
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("fname,expect", flat_dict({
|
@pytest.mark.parametrize(("fname", "expect"), flat_dict({
|
||||||
'index.html': [
|
'index.html': [
|
||||||
(FIGURE_CAPTION + "/span[@class='caption-number']", None, True),
|
(FIGURE_CAPTION + "/span[@class='caption-number']", None, True),
|
||||||
(".//table/caption/span[@class='caption-number']", None, True),
|
(".//table/caption/span[@class='caption-number']", None, True),
|
||||||
@ -674,7 +674,7 @@ def test_numfig_without_numbered_toctree_warn(app, warning):
|
|||||||
assert 'index.rst:57: WARNING: invalid numfig_format: Fig %s %s' in warnings
|
assert 'index.rst:57: WARNING: invalid numfig_format: Fig %s %s' in warnings
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("fname,expect", flat_dict({
|
@pytest.mark.parametrize(("fname", "expect"), flat_dict({
|
||||||
'index.html': [
|
'index.html': [
|
||||||
(FIGURE_CAPTION + "/span[@class='caption-number']", '^Fig. 9 $', True),
|
(FIGURE_CAPTION + "/span[@class='caption-number']", '^Fig. 9 $', True),
|
||||||
(FIGURE_CAPTION + "/span[@class='caption-number']", '^Fig. 10 $', True),
|
(FIGURE_CAPTION + "/span[@class='caption-number']", '^Fig. 10 $', True),
|
||||||
@ -770,7 +770,7 @@ def test_numfig_with_numbered_toctree_warn(app, warning):
|
|||||||
assert 'index.rst:57: WARNING: invalid numfig_format: Fig %s %s' in warnings
|
assert 'index.rst:57: WARNING: invalid numfig_format: Fig %s %s' in warnings
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("fname,expect", flat_dict({
|
@pytest.mark.parametrize(("fname", "expect"), flat_dict({
|
||||||
'index.html': [
|
'index.html': [
|
||||||
(FIGURE_CAPTION + "/span[@class='caption-number']", '^Fig. 1 $', True),
|
(FIGURE_CAPTION + "/span[@class='caption-number']", '^Fig. 1 $', True),
|
||||||
(FIGURE_CAPTION + "/span[@class='caption-number']", '^Fig. 2 $', True),
|
(FIGURE_CAPTION + "/span[@class='caption-number']", '^Fig. 2 $', True),
|
||||||
@ -863,7 +863,7 @@ def test_numfig_with_prefix_warn(app, warning):
|
|||||||
assert 'index.rst:57: WARNING: invalid numfig_format: Fig %s %s' in warnings
|
assert 'index.rst:57: WARNING: invalid numfig_format: Fig %s %s' in warnings
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("fname,expect", flat_dict({
|
@pytest.mark.parametrize(("fname", "expect"), flat_dict({
|
||||||
'index.html': [
|
'index.html': [
|
||||||
(FIGURE_CAPTION + "/span[@class='caption-number']", '^Figure:1 $', True),
|
(FIGURE_CAPTION + "/span[@class='caption-number']", '^Figure:1 $', True),
|
||||||
(FIGURE_CAPTION + "/span[@class='caption-number']", '^Figure:2 $', True),
|
(FIGURE_CAPTION + "/span[@class='caption-number']", '^Figure:2 $', True),
|
||||||
@ -957,7 +957,7 @@ def test_numfig_with_secnum_depth_warn(app, warning):
|
|||||||
assert 'index.rst:57: WARNING: invalid numfig_format: Fig %s %s' in warnings
|
assert 'index.rst:57: WARNING: invalid numfig_format: Fig %s %s' in warnings
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("fname,expect", flat_dict({
|
@pytest.mark.parametrize(("fname", "expect"), flat_dict({
|
||||||
'index.html': [
|
'index.html': [
|
||||||
(FIGURE_CAPTION + "/span[@class='caption-number']", '^Fig. 1 $', True),
|
(FIGURE_CAPTION + "/span[@class='caption-number']", '^Fig. 1 $', True),
|
||||||
(FIGURE_CAPTION + "/span[@class='caption-number']", '^Fig. 2 $', True),
|
(FIGURE_CAPTION + "/span[@class='caption-number']", '^Fig. 2 $', True),
|
||||||
@ -1036,7 +1036,7 @@ def test_numfig_with_secnum_depth(app, cached_etree_parse, fname, expect):
|
|||||||
check_xpath(cached_etree_parse(app.outdir / fname), fname, *expect)
|
check_xpath(cached_etree_parse(app.outdir / fname), fname, *expect)
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("fname,expect", flat_dict({
|
@pytest.mark.parametrize(("fname", "expect"), flat_dict({
|
||||||
'index.html': [
|
'index.html': [
|
||||||
(FIGURE_CAPTION + "/span[@class='caption-number']", '^Fig. 1 $', True),
|
(FIGURE_CAPTION + "/span[@class='caption-number']", '^Fig. 1 $', True),
|
||||||
(FIGURE_CAPTION + "/span[@class='caption-number']", '^Fig. 2 $', True),
|
(FIGURE_CAPTION + "/span[@class='caption-number']", '^Fig. 2 $', True),
|
||||||
@ -1107,7 +1107,7 @@ def test_numfig_with_singlehtml(app, cached_etree_parse, fname, expect):
|
|||||||
check_xpath(cached_etree_parse(app.outdir / fname), fname, *expect)
|
check_xpath(cached_etree_parse(app.outdir / fname), fname, *expect)
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("fname,expect", flat_dict({
|
@pytest.mark.parametrize(("fname", "expect"), flat_dict({
|
||||||
'index.html': [
|
'index.html': [
|
||||||
(FIGURE_CAPTION + "//span[@class='caption-number']", "Fig. 1", True),
|
(FIGURE_CAPTION + "//span[@class='caption-number']", "Fig. 1", True),
|
||||||
(FIGURE_CAPTION + "//span[@class='caption-number']", "Fig. 2", True),
|
(FIGURE_CAPTION + "//span[@class='caption-number']", "Fig. 2", True),
|
||||||
@ -1346,7 +1346,7 @@ def test_html_raw_directive(app, status, warning):
|
|||||||
assert '<p>LaTeX: abc ghi</p>' in result
|
assert '<p>LaTeX: abc ghi</p>' in result
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("fname,expect", flat_dict({
|
@pytest.mark.parametrize(("fname", "expect"), flat_dict({
|
||||||
'index.html': [
|
'index.html': [
|
||||||
(".//link[@href='_static/persistent.css']"
|
(".//link[@href='_static/persistent.css']"
|
||||||
"[@rel='stylesheet']", '', True),
|
"[@rel='stylesheet']", '', True),
|
||||||
@ -1470,7 +1470,7 @@ def test_html_sidebar(app, status, warning):
|
|||||||
assert ctx['sidebars'] == []
|
assert ctx['sidebars'] == []
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize('fname,expect', flat_dict({
|
@pytest.mark.parametrize(("fname", "expect"), flat_dict({
|
||||||
'index.html': [(".//em/a[@href='https://example.com/man.1']", "", True),
|
'index.html': [(".//em/a[@href='https://example.com/man.1']", "", True),
|
||||||
(".//em/a[@href='https://example.com/ls.1']", "", True),
|
(".//em/a[@href='https://example.com/ls.1']", "", True),
|
||||||
(".//em/a[@href='https://example.com/sphinx.']", "", True)],
|
(".//em/a[@href='https://example.com/sphinx.']", "", True)],
|
||||||
|
@ -95,7 +95,7 @@ def skip_if_stylefiles_notfound(testfunc):
|
|||||||
@skip_if_requested
|
@skip_if_requested
|
||||||
@skip_if_stylefiles_notfound
|
@skip_if_stylefiles_notfound
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
"engine,docclass,python_maximum_signature_line_length",
|
('engine', 'docclass', 'python_maximum_signature_line_length'),
|
||||||
# Only running test with `python_maximum_signature_line_length` not None with last
|
# Only running test with `python_maximum_signature_line_length` not None with last
|
||||||
# LaTeX engine to reduce testing time, as if this configuration does not fail with
|
# LaTeX engine to reduce testing time, as if this configuration does not fail with
|
||||||
# one engine, it's almost impossible it would fail with another.
|
# one engine, it's almost impossible it would fail with another.
|
||||||
|
@ -244,7 +244,7 @@ TYPECHECK_WARNINGS = [
|
|||||||
|
|
||||||
|
|
||||||
@mock.patch("sphinx.config.logger")
|
@mock.patch("sphinx.config.logger")
|
||||||
@pytest.mark.parametrize("name,default,annotation,actual,warned", TYPECHECK_WARNINGS)
|
@pytest.mark.parametrize(('name', 'default', 'annotation', 'actual', 'warned'), TYPECHECK_WARNINGS)
|
||||||
def test_check_types(logger, name, default, annotation, actual, warned):
|
def test_check_types(logger, name, default, annotation, actual, warned):
|
||||||
config = Config({name: actual})
|
config = Config({name: actual})
|
||||||
config.add(name, default, 'env', annotation or ())
|
config.add(name, default, 'env', annotation or ())
|
||||||
@ -264,7 +264,7 @@ TYPECHECK_WARNING_MESSAGES = [
|
|||||||
|
|
||||||
|
|
||||||
@mock.patch("sphinx.config.logger")
|
@mock.patch("sphinx.config.logger")
|
||||||
@pytest.mark.parametrize("name,default,annotation,actual,message", TYPECHECK_WARNING_MESSAGES)
|
@pytest.mark.parametrize(('name', 'default', 'annotation', 'actual', 'message'), TYPECHECK_WARNING_MESSAGES)
|
||||||
def test_conf_warning_message(logger, name, default, annotation, actual, message):
|
def test_conf_warning_message(logger, name, default, annotation, actual, message):
|
||||||
config = Config({name: actual})
|
config = Config({name: actual})
|
||||||
config.add(name, default, False, annotation or ())
|
config.add(name, default, False, annotation or ())
|
||||||
|
@ -1062,7 +1062,7 @@ def test_domain_cpp_ast_xref_parsing():
|
|||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
'param,is_pack',
|
("param", "is_pack"),
|
||||||
[('typename', False),
|
[('typename', False),
|
||||||
('typename T', False),
|
('typename T', False),
|
||||||
('typename...', True),
|
('typename...', True),
|
||||||
|
@ -2078,7 +2078,7 @@ def test_class_def_pep_696(app):
|
|||||||
))
|
))
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize('tp_list,tptext', [
|
@pytest.mark.parametrize(('tp_list', 'tptext'), [
|
||||||
('[T:int]', '[T: int]'),
|
('[T:int]', '[T: int]'),
|
||||||
('[T:*Ts]', '[T: *Ts]'),
|
('[T:*Ts]', '[T: *Ts]'),
|
||||||
('[T:int|(*Ts)]', '[T: int | (*Ts)]'),
|
('[T:int|(*Ts)]', '[T: int | (*Ts)]'),
|
||||||
@ -2093,7 +2093,7 @@ def test_pep_695_and_pep_696_whitespaces_in_bound(app, tp_list, tptext):
|
|||||||
assert doctree.astext() == f'\n\nf{tptext}()\n\n'
|
assert doctree.astext() == f'\n\nf{tptext}()\n\n'
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize('tp_list,tptext', [
|
@pytest.mark.parametrize(('tp_list', 'tptext'), [
|
||||||
('[T:(int,str)]', '[T: (int, str)]'),
|
('[T:(int,str)]', '[T: (int, str)]'),
|
||||||
('[T:(int|str,*Ts)]', '[T: (int | str, *Ts)]'),
|
('[T:(int|str,*Ts)]', '[T: (int | str, *Ts)]'),
|
||||||
])
|
])
|
||||||
@ -2103,7 +2103,7 @@ def test_pep_695_and_pep_696_whitespaces_in_constraints(app, tp_list, tptext):
|
|||||||
assert doctree.astext() == f'\n\nf{tptext}()\n\n'
|
assert doctree.astext() == f'\n\nf{tptext}()\n\n'
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize('tp_list,tptext', [
|
@pytest.mark.parametrize(('tp_list', 'tptext'), [
|
||||||
('[T=int]', '[T = int]'),
|
('[T=int]', '[T = int]'),
|
||||||
('[T:int=int]', '[T: int = int]'),
|
('[T:int=int]', '[T: int = int]'),
|
||||||
('[*V=*Ts]', '[*V = *Ts]'),
|
('[*V=*Ts]', '[*V = *Ts]'),
|
||||||
|
@ -149,7 +149,7 @@ def get_verifier(verify, verify_re):
|
|||||||
return get
|
return get
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize('type,rst,html_expected,latex_expected', [
|
@pytest.mark.parametrize(('type', 'rst', 'html_expected', 'latex_expected'), [
|
||||||
(
|
(
|
||||||
# pep role
|
# pep role
|
||||||
'verify',
|
'verify',
|
||||||
@ -395,7 +395,7 @@ def test_inline(get_verifier, type, rst, html_expected, latex_expected):
|
|||||||
verifier(rst, html_expected, latex_expected)
|
verifier(rst, html_expected, latex_expected)
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize('type,rst,html_expected,latex_expected', [
|
@pytest.mark.parametrize(('type', 'rst', 'html_expected', 'latex_expected'), [
|
||||||
(
|
(
|
||||||
'verify',
|
'verify',
|
||||||
r'4 backslashes \\\\',
|
r'4 backslashes \\\\',
|
||||||
@ -409,7 +409,7 @@ def test_inline_docutils16(get_verifier, type, rst, html_expected, latex_expecte
|
|||||||
|
|
||||||
|
|
||||||
@pytest.mark.sphinx(confoverrides={'latex_engine': 'xelatex'})
|
@pytest.mark.sphinx(confoverrides={'latex_engine': 'xelatex'})
|
||||||
@pytest.mark.parametrize('type,rst,html_expected,latex_expected', [
|
@pytest.mark.parametrize(('type', 'rst', 'html_expected', 'latex_expected'), [
|
||||||
(
|
(
|
||||||
# in verbatim code fragments
|
# in verbatim code fragments
|
||||||
'verify',
|
'verify',
|
||||||
|
@ -7,7 +7,7 @@ import pytest
|
|||||||
from sphinx.pycode.ast import unparse as ast_unparse
|
from sphinx.pycode.ast import unparse as ast_unparse
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize('source,expected', [
|
@pytest.mark.parametrize(('source', 'expected'), [
|
||||||
("a + b", "a + b"), # Add
|
("a + b", "a + b"), # Add
|
||||||
("a and b", "a and b"), # And
|
("a and b", "a and b"), # And
|
||||||
("os.path", "os.path"), # Attribute
|
("os.path", "os.path"), # Attribute
|
||||||
|
@ -93,7 +93,7 @@ def test_NodeMatcher():
|
|||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
'rst,node_cls,count',
|
('rst', 'node_cls', 'count'),
|
||||||
[
|
[
|
||||||
(
|
(
|
||||||
"""
|
"""
|
||||||
@ -187,7 +187,7 @@ def test_clean_astext():
|
|||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
'prefix, term, expected',
|
('prefix', 'term', 'expected'),
|
||||||
[
|
[
|
||||||
('', '', 'id0'),
|
('', '', 'id0'),
|
||||||
('term', '', 'term-0'),
|
('term', '', 'term-0'),
|
||||||
@ -220,7 +220,7 @@ def test_make_id_sequential(app):
|
|||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
'title, expected',
|
('title', 'expected'),
|
||||||
[
|
[
|
||||||
# implicit
|
# implicit
|
||||||
('hello', (False, 'hello', 'hello')),
|
('hello', (False, 'hello', 'hello')),
|
||||||
|
Loading…
Reference in New Issue
Block a user