55steps are not implemented.
66"""
77
8- import pytest
9-
108from pathlib import Path
9+ from typing import Any , Callable
1110
11+ import pytest
1212from pytest_bdd .feature import get_features
1313from pytest_bdd .scenario import get_features_base_dir
1414from pytest_bdd .utils import get_caller_module_path
@@ -22,15 +22,16 @@ def pytest_configure() -> None:
2222
2323 Args:
2424 config (Config): Configuration provided by pytest.
25-
2625 """
2726 conftest_dir = Path (__file__ ).parent
2827 caller_module_path = Path (get_caller_module_path ())
2928 features_base_dir = Path (get_features_base_dir (caller_module_path ))
30- if features_base_dir .exists ():
31- features = get_features ([features_base_dir ])
32- else :
33- features = []
29+
30+ features = (
31+ get_features ([features_base_dir ])
32+ if features_base_dir .exists ()
33+ else []
34+ )
3435
3536 for feat in features :
3637 feature_dir = Path (feat .filename ).parent
@@ -40,13 +41,13 @@ def pytest_configure() -> None:
4041 file_name = Path (feat .filename ).stem + "_test.py"
4142 file_path = file_dir / file_name
4243 feature_rel_path = Path (feat .filename ).relative_to (features_base_dir )
44+
4345 txt = (
44- '"""Feature steps implementation.\n '
45- "\n "
46- f'Source file: { feature_rel_path } \n """\n '
47- "from pytest_bdd import scenarios\n "
48- "\n "
49- f"""scenarios("{ feature_rel_path } ")"""
46+ '"""Feature steps implementation.\n \n '
47+ f"Source file: { feature_rel_path } \n "
48+ '"""\n '
49+ "from pytest_bdd import scenarios\n \n "
50+ f'scenarios("{ feature_rel_path } ")'
5051 )
5152
5253 file_dir .mkdir (parents = True , exist_ok = True )
@@ -56,11 +57,18 @@ def pytest_configure() -> None:
5657 f .write (txt )
5758
5859
59- def pytest_bdd_apply_tag (tag , function ):
60- if tag == 'todo' :
60+ def pytest_bdd_apply_tag (tag : str , function : Callable [..., Any ]) -> bool | None :
61+ """Apply custom tag behavior for pytest-bdd.
62+
63+ Args:
64+ tag (str): The tag specified in the feature file.
65+ function (Callable): The test function the tag applies to.
66+
67+ Returns:
68+ bool | None: True if the tag was handled, otherwise None.
69+ """
70+ if tag == "todo" :
6171 marker = pytest .mark .skip (reason = "Not implemented yet" )
6272 marker (function )
6373 return True
64- else :
65- # Fall back to the default behavior of pytest-bdd
66- return None
74+ return None
0 commit comments