Skip to content

Commit fec3001

Browse files
LouisTsai-Csiemarioevz
authored andcommitted
doc: update state marker
1 parent 7884d1c commit fec3001

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
@@ -431,6 +431,7 @@ def create_function_page_props(self, test_functions: Dict["str", List[Item]]) ->
431431
)
432432

433433
is_benchmark = items[0].get_closest_marker("benchmark") is not None
434+
is_state = items[0].get_closest_marker("state") is not None
434435

435436
self.function_page_props[function_id] = FunctionPageProps(
436437
title=get_test_function_name(items[0]),
@@ -447,6 +448,7 @@ def create_function_page_props(self, test_functions: Dict["str", List[Item]]) ->
447448
html_static_page_target=f"./{get_test_function_name(items[0])}.html",
448449
mkdocs_function_page_target=f"./{get_test_function_name(items[0])}/",
449450
is_benchmark=is_benchmark,
451+
is_state=is_state,
450452
)
451453

452454
def create_module_page_props(self) -> None:
@@ -462,6 +464,7 @@ def create_module_page_props(self) -> None:
462464
pytest_node_id=str(module_path),
463465
package_name=get_import_path(module_path),
464466
is_benchmark=function_page.is_benchmark,
467+
is_state=function_page.is_state,
465468
test_functions=[
466469
TestFunction(
467470
name=function_page.title,
@@ -475,6 +478,8 @@ def create_module_page_props(self) -> None:
475478
existing_module_page = self.module_page_props[str(function_page.path)]
476479
if function_page.is_benchmark:
477480
existing_module_page.is_benchmark = True
481+
if function_page.is_state:
482+
existing_module_page.is_state = True
478483
existing_module_page.test_functions.append(
479484
TestFunction(
480485
name=function_page.title,
@@ -511,7 +516,12 @@ def add_directory_page_props(self) -> None:
511516
is_benchmark = any(
512517
module_page.is_benchmark
513518
for module_page in self.module_page_props.values()
514-
if module_page.path.parent == directory
519+
if directory in module_page.path.parents or module_page.path.parent == directory
520+
)
521+
is_state = any(
522+
module_page.is_state
523+
for module_page in self.module_page_props.values()
524+
if directory in module_page.path.parents or module_page.path.parent == directory
515525
)
516526

517527
self.page_props[str(directory)] = DirectoryPageProps(
@@ -526,6 +536,7 @@ def add_directory_page_props(self) -> None:
526536
# init.py will be used for docstrings
527537
package_name=get_import_path(directory),
528538
is_benchmark=is_benchmark,
539+
is_state=is_state,
529540
)
530541

531542
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
@@ -111,6 +111,7 @@ class PagePropsBase:
111111
pytest_node_id: str
112112
package_name: str
113113
is_benchmark: bool = False
114+
is_state: bool = False
114115

115116
@property
116117
@abstractmethod

0 commit comments

Comments
 (0)