Skip to content

Commit a06bd60

Browse files
doc: update state marker
1 parent 9773440 commit a06bd60

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

docs/templates/base.md.j2

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ Documentation for [`{{ pytest_node_id }}@{{ short_git_ref }}`]({{ source_code_ur
1111
```console
1212
{% if is_benchmark %}
1313
fill -v {{ pytest_node_id }} -m benchmark
14+
{% elif is_state %}
15+
fill -v {{ pytest_node_id }} -m state
1416
{% else %}
1517
fill -v {{ pytest_node_id }} --fork {{ target_or_valid_fork }}
1618
{% endif %}

src/pytest_plugins/filler/gen_test_doc/gen_test_doc.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,7 @@ def create_function_page_props(self, test_functions: Dict["str", List[Item]]) ->
424424
)
425425

426426
is_benchmark = items[0].get_closest_marker("benchmark") is not None
427+
is_state = items[0].get_closest_marker("state") is not None
427428

428429
self.function_page_props[function_id] = FunctionPageProps(
429430
title=get_test_function_name(items[0]),
@@ -440,6 +441,7 @@ def create_function_page_props(self, test_functions: Dict["str", List[Item]]) ->
440441
html_static_page_target=f"./{get_test_function_name(items[0])}.html",
441442
mkdocs_function_page_target=f"./{get_test_function_name(items[0])}/",
442443
is_benchmark=is_benchmark,
444+
is_state=is_state,
443445
)
444446

445447
def create_module_page_props(self) -> None:
@@ -455,6 +457,7 @@ def create_module_page_props(self) -> None:
455457
pytest_node_id=str(module_path),
456458
package_name=get_import_path(module_path),
457459
is_benchmark=function_page.is_benchmark,
460+
is_state=function_page.is_state,
458461
test_functions=[
459462
TestFunction(
460463
name=function_page.title,
@@ -468,6 +471,8 @@ def create_module_page_props(self) -> None:
468471
existing_module_page = self.module_page_props[str(function_page.path)]
469472
if function_page.is_benchmark:
470473
existing_module_page.is_benchmark = True
474+
if function_page.is_state:
475+
existing_module_page.is_state = True
471476
existing_module_page.test_functions.append(
472477
TestFunction(
473478
name=function_page.title,
@@ -503,7 +508,12 @@ def add_directory_page_props(self) -> None:
503508
is_benchmark = any(
504509
module_page.is_benchmark
505510
for module_page in self.module_page_props.values()
506-
if module_page.path.parent == directory
511+
if directory in module_page.path.parents or module_page.path.parent == directory
512+
)
513+
is_state = any(
514+
module_page.is_state
515+
for module_page in self.module_page_props.values()
516+
if directory in module_page.path.parents or module_page.path.parent == directory
507517
)
508518

509519
self.page_props[str(directory)] = DirectoryPageProps(
@@ -516,6 +526,7 @@ def add_directory_page_props(self) -> None:
516526
target_or_valid_fork=fork.capitalize() if fork else "Unknown",
517527
package_name=get_import_path(directory), # init.py will be used for docstrings
518528
is_benchmark=is_benchmark,
529+
is_state=is_state,
519530
)
520531

521532
def find_files_within_collection_scope(self, file_pattern: str) -> List[Path]:

src/pytest_plugins/filler/gen_test_doc/page_props.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ class PagePropsBase:
105105
pytest_node_id: str
106106
package_name: str
107107
is_benchmark: bool = False
108+
is_state: bool = False
108109

109110
@property
110111
@abstractmethod

0 commit comments

Comments
 (0)