From 133a76b65b778e1eb935b56d9398e3e9dd04595b Mon Sep 17 00:00:00 2001 From: barneygale Date: Sat, 6 Jan 2024 16:45:15 +0000 Subject: [PATCH] GH-113528: pathlib ABC tests: add repr to dummy path classes. 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 3a7c036077e2a1..bfde5f3c11ba8a 100644 --- a/Lib/test/test_pathlib/test_pathlib_abc.py +++ b/Lib/test/test_pathlib/test_pathlib_abc.py @@ -51,6 +51,9 @@ def __eq__(self, other): 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 @@ def __eq__(self, other): 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())