]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
GH-113528: pathlib ABC tests: add repr to dummy path classes. (#113777)
authorBarney Gale <barney.gale@gmail.com>
Sat, 6 Jan 2024 17:02:36 +0000 (17:02 +0000)
committerGitHub <noreply@github.com>
Sat, 6 Jan 2024 17:02:36 +0000 (17:02 +0000)
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

index 3a7c036077e2a13124ce2319c4238138dd4c6524..bfde5f3c11ba8a045ada2c21f886ab5762101d3a 100644 (file)
@@ -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())