Skip to content

Commit 1d4448f

Browse files
authored
Use subtests in tests/test_docs.py (#2609)
Closes #2608
1 parent 2ca00b6 commit 1d4448f

File tree

2 files changed

+30
-25
lines changed

2 files changed

+30
-25
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ docs = [
6969
"ruamel.yaml",
7070
]
7171
test = [
72-
"pytest>=5.2.2",
72+
"pytest>=9",
7373
"pytest-xdist>=2.2.1",
7474
"pytest-asyncio>=1.2.0",
7575
"beautifulsoup4>=4.8.1",

tests/test_docs.py

Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -28,31 +28,32 @@ def settings_headings():
2828
return get_headings((docs_path / "settings.rst").read_text(), "~")
2929

3030

31-
@pytest.mark.parametrize("setting", app.SETTINGS)
32-
def test_settings_are_documented(settings_headings, setting):
33-
assert setting.name in settings_headings
31+
def test_settings_are_documented(settings_headings, subtests):
32+
for setting in app.SETTINGS:
33+
with subtests.test(setting=setting.name):
34+
assert setting.name in settings_headings
3435

3536

3637
@pytest.fixture(scope="session")
3738
def plugin_hooks_content():
3839
return (docs_path / "plugin_hooks.rst").read_text()
3940

4041

41-
@pytest.mark.parametrize(
42-
"plugin", [name for name in dir(app.pm.hook) if not name.startswith("_")]
43-
)
44-
def test_plugin_hooks_are_documented(plugin, plugin_hooks_content):
42+
def test_plugin_hooks_are_documented(plugin_hooks_content, subtests):
4543
headings = set()
4644
headings.update(get_headings(plugin_hooks_content, "-"))
4745
headings.update(get_headings(plugin_hooks_content, "~"))
48-
assert plugin in headings
49-
hook_caller = getattr(app.pm.hook, plugin)
50-
arg_names = [a for a in hook_caller.spec.argnames if a != "__multicall__"]
51-
# Check for plugin_name(arg1, arg2, arg3)
52-
expected = f"{plugin}({', '.join(arg_names)})"
53-
assert (
54-
expected in plugin_hooks_content
55-
), f"Missing from plugin hook documentation: {expected}"
46+
plugins = [name for name in dir(app.pm.hook) if not name.startswith("_")]
47+
for plugin in plugins:
48+
with subtests.test(plugin=plugin):
49+
assert plugin in headings
50+
hook_caller = getattr(app.pm.hook, plugin)
51+
arg_names = [a for a in hook_caller.spec.argnames if a != "__multicall__"]
52+
# Check for plugin_name(arg1, arg2, arg3)
53+
expected = f"{plugin}({', '.join(arg_names)})"
54+
assert (
55+
expected in plugin_hooks_content
56+
), f"Missing from plugin hook documentation: {expected}"
5657

5758

5859
@pytest.fixture(scope="session")
@@ -68,9 +69,11 @@ def documented_views():
6869
return view_labels
6970

7071

71-
@pytest.mark.parametrize("view_class", [v for v in dir(app) if v.endswith("View")])
72-
def test_view_classes_are_documented(documented_views, view_class):
73-
assert view_class in documented_views
72+
def test_view_classes_are_documented(documented_views, subtests):
73+
view_classes = [v for v in dir(app) if v.endswith("View")]
74+
for view_class in view_classes:
75+
with subtests.test(view_class=view_class):
76+
assert view_class in documented_views
7477

7578

7679
@pytest.fixture(scope="session")
@@ -85,9 +88,10 @@ def documented_table_filters():
8588
}
8689

8790

88-
@pytest.mark.parametrize("filter", [f.key for f in Filters._filters])
89-
def test_table_filters_are_documented(documented_table_filters, filter):
90-
assert filter in documented_table_filters
91+
def test_table_filters_are_documented(documented_table_filters, subtests):
92+
for f in Filters._filters:
93+
with subtests.test(filter=f.key):
94+
assert f.key in documented_table_filters
9195

9296

9397
@pytest.fixture(scope="session")
@@ -101,9 +105,10 @@ def documented_fns():
101105
}
102106

103107

104-
@pytest.mark.parametrize("fn", utils.functions_marked_as_documented)
105-
def test_functions_marked_with_documented_are_documented(documented_fns, fn):
106-
assert fn.__name__ in documented_fns
108+
def test_functions_marked_with_documented_are_documented(documented_fns, subtests):
109+
for fn in utils.functions_marked_as_documented:
110+
with subtests.test(fn=fn.__name__):
111+
assert fn.__name__ in documented_fns
107112

108113

109114
def test_rst_heading_underlines_match_title_length():

0 commit comments

Comments
 (0)