hide pytest-bdd internal method in user traceback
This commit is contained in:
parent
f6865058c3
commit
64e2086cdf
|
@ -48,7 +48,7 @@ def get_feature(base_path: str, filename: str, encoding: str = "utf-8") -> Featu
|
||||||
stored in the global variable cache to improve the performance
|
stored in the global variable cache to improve the performance
|
||||||
when multiple scenarios are referencing the same file.
|
when multiple scenarios are referencing the same file.
|
||||||
"""
|
"""
|
||||||
|
__tracebackhide__ = True
|
||||||
full_name = os.path.abspath(os.path.join(base_path, filename))
|
full_name = os.path.abspath(os.path.join(base_path, filename))
|
||||||
feature = features.get(full_name)
|
feature = features.get(full_name)
|
||||||
if not feature:
|
if not feature:
|
||||||
|
|
|
@ -88,6 +88,7 @@ def parse_feature(basedir: str, filename: str, encoding: str = "utf-8") -> Featu
|
||||||
:param str filename: Relative path to the feature file.
|
:param str filename: Relative path to the feature file.
|
||||||
:param str encoding: Feature file encoding (utf-8 by default).
|
:param str encoding: Feature file encoding (utf-8 by default).
|
||||||
"""
|
"""
|
||||||
|
__tracebackhide__ = True
|
||||||
abs_filename = os.path.abspath(os.path.join(basedir, filename))
|
abs_filename = os.path.abspath(os.path.join(basedir, filename))
|
||||||
rel_filename = os.path.join(os.path.basename(basedir), filename)
|
rel_filename = os.path.join(os.path.basename(basedir), filename)
|
||||||
feature = Feature(
|
feature = Feature(
|
||||||
|
|
|
@ -110,6 +110,7 @@ def get_step_function(request, step: Step) -> StepFunctionContext | None:
|
||||||
|
|
||||||
Finally we let request.getfixturevalue(...) fetch the step definition fixture.
|
Finally we let request.getfixturevalue(...) fetch the step definition fixture.
|
||||||
"""
|
"""
|
||||||
|
__tracebackhide__ = True
|
||||||
bdd_name = get_step_fixture_name(step=step)
|
bdd_name = get_step_fixture_name(step=step)
|
||||||
|
|
||||||
with inject_fixturedefs_for_step(step=step, fixturemanager=request._fixturemanager, nodeid=request.node.nodeid):
|
with inject_fixturedefs_for_step(step=step, fixturemanager=request._fixturemanager, nodeid=request.node.nodeid):
|
||||||
|
@ -123,6 +124,7 @@ def _execute_step_function(
|
||||||
request: FixtureRequest, scenario: Scenario, step: Step, context: StepFunctionContext
|
request: FixtureRequest, scenario: Scenario, step: Step, context: StepFunctionContext
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Execute step function."""
|
"""Execute step function."""
|
||||||
|
__tracebackhide__ = True
|
||||||
kw = {
|
kw = {
|
||||||
"request": request,
|
"request": request,
|
||||||
"feature": scenario.feature,
|
"feature": scenario.feature,
|
||||||
|
@ -173,6 +175,7 @@ def _execute_scenario(feature: Feature, scenario: Scenario, request: FixtureRequ
|
||||||
:param request: request.
|
:param request: request.
|
||||||
:param encoding: Encoding.
|
:param encoding: Encoding.
|
||||||
"""
|
"""
|
||||||
|
__tracebackhide__ = True
|
||||||
request.config.hook.pytest_bdd_before_scenario(request=request, feature=feature, scenario=scenario)
|
request.config.hook.pytest_bdd_before_scenario(request=request, feature=feature, scenario=scenario)
|
||||||
|
|
||||||
for step in scenario.steps:
|
for step in scenario.steps:
|
||||||
|
@ -214,6 +217,7 @@ def _get_scenario_decorator(
|
||||||
# otherwise indirect fixtures would not work.
|
# otherwise indirect fixtures would not work.
|
||||||
@pytest.mark.usefixtures(*func_args)
|
@pytest.mark.usefixtures(*func_args)
|
||||||
def scenario_wrapper(request: FixtureRequest, _pytest_bdd_example: dict[str, str]) -> Any:
|
def scenario_wrapper(request: FixtureRequest, _pytest_bdd_example: dict[str, str]) -> Any:
|
||||||
|
__tracebackhide__ = True
|
||||||
scenario = templated_scenario.render(_pytest_bdd_example)
|
scenario = templated_scenario.render(_pytest_bdd_example)
|
||||||
_execute_scenario(feature, scenario, request)
|
_execute_scenario(feature, scenario, request)
|
||||||
fixture_values = [request.getfixturevalue(arg) for arg in func_args]
|
fixture_values = [request.getfixturevalue(arg) for arg in func_args]
|
||||||
|
@ -259,7 +263,7 @@ def scenario(
|
||||||
:param str scenario_name: Scenario name.
|
:param str scenario_name: Scenario name.
|
||||||
:param str encoding: Feature file encoding.
|
:param str encoding: Feature file encoding.
|
||||||
"""
|
"""
|
||||||
|
__tracebackhide__ = True
|
||||||
scenario_name = str(scenario_name)
|
scenario_name = str(scenario_name)
|
||||||
caller_module_path = get_caller_module_path()
|
caller_module_path = get_caller_module_path()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue