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

Class Step

src/pytest_bdd/parser.py:264–341  ·  view source on GitHub ↗

Represents a step within a scenario or background. Attributes: type (str): The type of step (e.g., 'given', 'when', 'then'). name (str): The name of the step. line_number (int): The line number where the step starts in the file. indent (int): The indentation leve

Source from the content-addressed store, hash-verified

262
263@dataclass(eq=False)
264class Step:
265 """Represents a step within a scenario or background.
266
267 Attributes:
268 type (str): The type of step (e.g., 'given', 'when', 'then').
269 name (str): The name of the step.
270 line_number (int): The line number where the step starts in the file.
271 indent (int): The indentation level of the step.
272 keyword (str): The keyword used for the step (e.g., 'Given', 'When', 'Then').
273 failed (bool): Whether the step has failed (internal use only).
274 scenario (Optional[ScenarioTemplate]): The scenario to which this step belongs (internal use only).
275 background (Optional[Background]): The background to which this step belongs (internal use only).
276 """
277
278 type: str
279 name: str
280 line_number: int
281 indent: int
282 keyword: str
283 docstring: str | None = None
284 datatable: DataTable | None = None
285 failed: bool = field(init=False, default=False)
286 scenario: ScenarioTemplate | None = field(init=False, default=None)
287 background: Background | None = field(init=False, default=None)
288
289 def __init__(
290 self,
291 name: str,
292 type: str,
293 indent: int,
294 line_number: int,
295 keyword: str,
296 datatable: DataTable | None = None,
297 docstring: str | None = None,
298 ) -> None:
299 """Initialize a step.
300
301 Args:
302 name (str): The name of the step.
303 type (str): The type of the step (e.g., 'given', 'when', 'then').
304 indent (int): The indentation level of the step.
305 line_number (int): The line number where the step starts in the file.
306 keyword (str): The keyword used for the step (e.g., 'Given', 'When', 'Then').
307 """
308 self.name = name
309 self.type = type
310 self.indent = indent
311 self.line_number = line_number
312 self.keyword = keyword
313 self.datatable = datatable
314 self.docstring = docstring
315
316 def __str__(self) -> str:
317 """Return a string representation of the step.
318
319 Returns:
320 str: A string representation of the step.
321 """

Callers 2

renderMethod · 0.70
parse_stepsMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…