The values passed to Subtests.test() that are included in the test report.
| 56 | |
| 57 | @dataclasses.dataclass(frozen=True, slots=True, kw_only=True) |
| 58 | class SubtestContext: |
| 59 | """The values passed to Subtests.test() that are included in the test report.""" |
| 60 | |
| 61 | msg: str | None |
| 62 | kwargs: Mapping[str, Any] |
| 63 | |
| 64 | def __post_init__(self) -> None: |
| 65 | # Brute-force the returned kwargs dict to be JSON serializable (pytest-dev/pytest-xdist#1273). |
| 66 | object.__setattr__( |
| 67 | self, "kwargs", {k: saferepr(v) for (k, v) in self.kwargs.items()} |
| 68 | ) |
| 69 | |
| 70 | def _to_json(self) -> dict[str, Any]: |
| 71 | result = dataclasses.asdict(self) |
| 72 | return result |
| 73 | |
| 74 | @classmethod |
| 75 | def _from_json(cls, d: dict[str, Any]) -> Self: |
| 76 | return cls(msg=d["msg"], kwargs=d["kwargs"]) |
| 77 | |
| 78 | |
| 79 | @dataclasses.dataclass(init=False) |
no outgoing calls