MCPcopy Create free account
hub / github.com/pytest-dev/pytest-bdd / print_missing_code

Function print_missing_code

src/pytest_bdd/generation.py:83–126  ·  view source on GitHub ↗

Print missing code with TerminalWriter.

(scenarios: list[ScenarioTemplate], steps: list[Step])

Source from the content-addressed store, hash-verified

81
82
83def print_missing_code(scenarios: list[ScenarioTemplate], steps: list[Step]) -> None:
84 """Print missing code with TerminalWriter."""
85 tw = TerminalWriter()
86 scenario = step = None
87
88 for scenario in scenarios:
89 tw.line()
90 tw.line(
91 (
92 f'Scenario "{scenario.name}" is not bound to any test in the feature "{scenario.feature.name}" '
93 f"in the file {scenario.feature.filename}:{scenario.line_number}"
94 ),
95 red=True,
96 )
97
98 if scenario:
99 tw.sep("-", red=True)
100
101 for step in steps:
102 tw.line()
103 if step.scenario is not None:
104 tw.line(
105 (
106 f'Step {step} is not defined in the scenario "{step.scenario.name}" '
107 f'in the feature "{step.scenario.feature.name}" in the file '
108 f"{step.scenario.feature.filename}:{step.line_number}"
109 ),
110 red=True,
111 )
112 elif step.background is not None:
113 message = f"Background step {step} is not defined."
114 tw.line(message, red=True)
115
116 if step:
117 tw.sep("-", red=True)
118
119 tw.line("Please place the code above to the test file(s):")
120 tw.line()
121
122 features = sorted(
123 (scenario.feature for scenario in scenarios), key=lambda feature: feature.name or feature.filename
124 )
125 code = generate_code(features, scenarios, steps)
126 tw.write(code)
127
128
129def _find_step_fixturedef(

Callers 1

_show_missing_code_mainFunction · 0.85

Calls 1

generate_codeFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…