Skip to content

hide pytest-bdd internal method in user tracebacks #557

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/pytest_bdd/feature.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
when multiple scenarios are referencing the same file.
"""

__tracebackhide__ = True
full_name = os.path.abspath(os.path.join(base_path, filename))
feature = features.get(full_name)
if not feature:
Expand Down
1 change: 1 addition & 0 deletions src/pytest_bdd/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 encoding: Feature file encoding (utf-8 by default).
"""
__tracebackhide__ = True
abs_filename = os.path.abspath(os.path.join(basedir, filename))
rel_filename = os.path.join(os.path.basename(basedir), filename)
feature = Feature(
Expand Down
6 changes: 5 additions & 1 deletion src/pytest_bdd/scenario.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ def get_step_function(request, step: Step) -> StepFunctionContext | None:

Finally we let request.getfixturevalue(...) fetch the step definition fixture.
"""
__tracebackhide__ = True
bdd_name = get_step_fixture_name(step=step)

with inject_fixturedefs_for_step(step=step, fixturemanager=request._fixturemanager, nodeid=request.node.nodeid):
Expand All @@ -123,6 +124,7 @@ def _execute_step_function(
request: FixtureRequest, scenario: Scenario, step: Step, context: StepFunctionContext
) -> None:
"""Execute step function."""
__tracebackhide__ = True
kw = {
"request": request,
"feature": scenario.feature,
Expand Down Expand Up @@ -173,6 +175,7 @@ def _execute_scenario(feature: Feature, scenario: Scenario, request: FixtureRequ
:param request: request.
:param encoding: Encoding.
"""
__tracebackhide__ = True
request.config.hook.pytest_bdd_before_scenario(request=request, feature=feature, scenario=scenario)

for step in scenario.steps:
Expand Down Expand Up @@ -214,6 +217,7 @@ def decorator(*args: Callable) -> Callable:
# otherwise indirect fixtures would not work.
@pytest.mark.usefixtures(*func_args)
def scenario_wrapper(request: FixtureRequest, _pytest_bdd_example: dict[str, str]) -> Any:
__tracebackhide__ = True
scenario = templated_scenario.render(_pytest_bdd_example)
_execute_scenario(feature, scenario, request)
fixture_values = [request.getfixturevalue(arg) for arg in func_args]
Expand Down Expand Up @@ -259,7 +263,7 @@ def scenario(
:param str scenario_name: Scenario name.
:param str encoding: Feature file encoding.
"""

__tracebackhide__ = True
scenario_name = str(scenario_name)
caller_module_path = get_caller_module_path()

Expand Down