19
19
import re
20
20
from collections .abc import Iterable , Iterator
21
21
from inspect import signature
22
- from typing import TYPE_CHECKING , Any , Callable , TypeVar , cast
22
+ from typing import TYPE_CHECKING , Callable , TypeVar , cast
23
23
from weakref import WeakKeyDictionary
24
24
25
25
import pytest
@@ -444,15 +444,17 @@ def get_name() -> str:
444
444
suffix = f"_{ index } "
445
445
446
446
447
- def scenarios (* feature_paths : str , ** kwargs : Any ) -> None :
447
+ def scenarios (* feature_paths : str , encoding : str = "utf-8" , features_base_dir : str | None = None ) -> None :
448
+ caller_locals = get_caller_module_locals ()
448
449
"""Parse features from the paths and put all found scenarios in the caller module.
449
450
450
451
:param *feature_paths: feature file paths to use for scenarios
452
+ :param str encoding: Feature file encoding.
453
+ :param features_base_dir: Optional base dir location for locating feature files. If not set, it will try and
454
+ resolve using property set in .ini file, otherwise it is assumed to be relative from the caller path location.
451
455
"""
452
- caller_locals = get_caller_module_locals ()
453
456
caller_path = get_caller_module_path ()
454
457
455
- features_base_dir = kwargs .get ("features_base_dir" )
456
458
if features_base_dir is None :
457
459
features_base_dir = get_features_base_dir (caller_path )
458
460
@@ -474,7 +476,7 @@ def scenarios(*feature_paths: str, **kwargs: Any) -> None:
474
476
# skip already bound scenarios
475
477
if (scenario_object .feature .filename , scenario_name ) not in module_scenarios :
476
478
477
- @scenario (feature .filename , scenario_name , ** kwargs )
479
+ @scenario (feature .filename , scenario_name , encoding = encoding , features_base_dir = features_base_dir )
478
480
def _scenario () -> None :
479
481
pass # pragma: no cover
480
482
0 commit comments