From d429a5a8e76e3013b35d60c78fcb891556ad9a7c Mon Sep 17 00:00:00 2001 From: Barney Gale Date: Sat, 6 Jan 2024 17:02:36 +0000 Subject: GH-113528: pathlib ABC tests: add repr to dummy path classes. (#113777) The `DummyPurePath` and `DummyPath` test classes are simple subclasses of `PurePathBase` and `PathBase`. This commit adds `__repr__()` methods to the dummy classes, which makes debugging test failures less painful. --- Lib/test/test_pathlib/test_pathlib_abc.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Lib/test/test_pathlib/test_pathlib_abc.py b/Lib/test/test_pathlib/test_pathlib_abc.py index 3a7c036..bfde5f3 100644 --- a/Lib/test/test_pathlib/test_pathlib_abc.py +++ b/Lib/test/test_pathlib/test_pathlib_abc.py @@ -51,6 +51,9 @@ class DummyPurePath(PurePathBase): def __hash__(self): return hash(str(self)) + def __repr__(self): + return "{}({!r})".format(self.__class__.__name__, self.as_posix()) + class DummyPurePathTest(unittest.TestCase): cls = DummyPurePath @@ -719,6 +722,9 @@ class DummyPath(PathBase): def __hash__(self): return hash(str(self)) + def __repr__(self): + return "{}({!r})".format(self.__class__.__name__, self.as_posix()) + def stat(self, *, follow_symlinks=True): if follow_symlinks: path = str(self.resolve()) -- cgit v0.12