()
| 172 | |
| 173 | |
| 174 | def test_pretty_dataclass() -> None: |
| 175 | dc = ExampleDataclass(1000, "Hello, World", 999, ["foo", "bar", "baz"]) |
| 176 | result = pretty_repr(dc, max_width=80) |
| 177 | print(repr(result)) |
| 178 | assert ( |
| 179 | result |
| 180 | == "ExampleDataclass(foo=1000, bar='Hello, World', baz=['foo', 'bar', 'baz'])" |
| 181 | ) |
| 182 | result = pretty_repr(dc, max_width=16) |
| 183 | print(repr(result)) |
| 184 | assert ( |
| 185 | result |
| 186 | == "ExampleDataclass(\n foo=1000,\n bar='Hello, World',\n baz=[\n 'foo',\n 'bar',\n 'baz'\n ]\n)" |
| 187 | ) |
| 188 | dc.bar = dc |
| 189 | result = pretty_repr(dc, max_width=80) |
| 190 | print(repr(result)) |
| 191 | assert result == "ExampleDataclass(foo=1000, bar=..., baz=['foo', 'bar', 'baz'])" |
| 192 | |
| 193 | |
| 194 | def test_empty_dataclass() -> None: |
nothing calls this directly
no test coverage detected