From: Barney Gale Date: Sat, 6 Jan 2024 17:02:36 +0000 (+0000) Subject: GH-113528: pathlib ABC tests: add repr to dummy path classes. (#113777) X-Git-Tag: v3.13.0a3~166 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d429a5a8e76e3013b35d60c78fcb891556ad9a7c;p=thirdparty%2FPython%2Fcpython.git 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. --- diff --git a/Lib/test/test_pathlib/test_pathlib_abc.py b/Lib/test/test_pathlib/test_pathlib_abc.py index 3a7c036077e2..bfde5f3c11ba 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())