Report attributes which are path-like should become strings.
(self, pytester: Pytester)
| 225 | assert newrep.longrepr == str(rep.longrepr) |
| 226 | |
| 227 | def test_paths_support(self, pytester: Pytester) -> None: |
| 228 | """Report attributes which are path-like should become strings.""" |
| 229 | pytester.makepyfile( |
| 230 | """ |
| 231 | def test_a(): |
| 232 | assert False |
| 233 | """ |
| 234 | ) |
| 235 | |
| 236 | class MyPathLike: |
| 237 | def __init__(self, path: str) -> None: |
| 238 | self.path = path |
| 239 | |
| 240 | def __fspath__(self) -> str: |
| 241 | return self.path |
| 242 | |
| 243 | reprec = pytester.inline_run() |
| 244 | reports = reprec.getreports("pytest_runtest_logreport") |
| 245 | assert len(reports) == 3 |
| 246 | test_a_call = reports[1] |
| 247 | test_a_call.path1 = MyPathLike(str(pytester.path)) # type: ignore[attr-defined] |
| 248 | test_a_call.path2 = pytester.path # type: ignore[attr-defined] |
| 249 | data = test_a_call._to_json() |
| 250 | assert data["path1"] == str(pytester.path) |
| 251 | assert data["path2"] == str(pytester.path) |
| 252 | |
| 253 | def test_deserialization_failure(self, pytester: Pytester) -> None: |
| 254 | """Check handling of failure during deserialization of report types.""" |
nothing calls this directly
no test coverage detected