MCPcopy
hub / github.com/pytest-dev/pytest / test_paths_support

Method test_paths_support

testing/test_reports.py:227–251  ·  view source on GitHub ↗

Report attributes which are path-like should become strings.

(self, pytester: Pytester)

Source from the content-addressed store, hash-verified

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."""

Callers

nothing calls this directly

Calls 5

MyPathLikeClass · 0.85
makepyfileMethod · 0.45
inline_runMethod · 0.45
getreportsMethod · 0.45
_to_jsonMethod · 0.45

Tested by

no test coverage detected