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

Class StepReport

src/pytest_bdd/reporting.py:23–70  ·  view source on GitHub ↗

Step execution report.

Source from the content-addressed store, hash-verified

21
22
23class StepReport:
24 """Step execution report."""
25
26 failed = False
27 stopped = None
28
29 def __init__(self, step: Step) -> None:
30 """Step report constructor.
31
32 :param pytest_bdd.parser.Step step: Step.
33 """
34 self.step = step
35 self.started = time.perf_counter()
36
37 def serialize(self) -> dict[str, Any]:
38 """Serialize the step execution report.
39
40 :return: Serialized step execution report.
41 :rtype: dict
42 """
43 return {
44 "name": self.step.name,
45 "type": self.step.type,
46 "keyword": self.step.keyword,
47 "line_number": self.step.line_number,
48 "failed": self.failed,
49 "duration": self.duration,
50 }
51
52 def finalize(self, failed: bool) -> None:
53 """Stop collecting information and finalize the report.
54
55 :param bool failed: Whether the step execution is failed.
56 """
57 self.stopped = time.perf_counter()
58 self.failed = failed
59
60 @property
61 def duration(self) -> float:
62 """Step execution duration.
63
64 :return: Step execution duration.
65 :rtype: float
66 """
67 if self.stopped is None:
68 return 0
69
70 return self.stopped - self.started
71
72
73class ScenarioReport:

Callers 2

failMethod · 0.85
before_stepFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…