The writer should accept dataclasses (Message subclasses are dataclasses) via ``asdict``.
(tmp_path: Path)
| 99 | |
| 100 | |
| 101 | def test_writer_dataclass_serialization(tmp_path: Path) -> None: |
| 102 | """The writer should accept dataclasses (Message subclasses are |
| 103 | dataclasses) via ``asdict``.""" |
| 104 | from dataclasses import dataclass |
| 105 | |
| 106 | @dataclass |
| 107 | class Stub: |
| 108 | field: str |
| 109 | n: int |
| 110 | |
| 111 | path = tmp_path / "x.jsonl" |
| 112 | with TranscriptWriter(path) as w: |
| 113 | w.append(Stub(field="hello", n=42)) |
| 114 | parsed = json.loads(path.read_text().strip()) |
| 115 | assert parsed == {"field": "hello", "n": 42} |
| 116 | |
| 117 | |
| 118 | def test_writer_unserializable_object_does_not_crash(tmp_path: Path) -> None: |
nothing calls this directly
no test coverage detected