[3.8] bpo-38878: Fix os.PathLike __subclasshook__ (GH-17336) (GH-17684)
https://bugs.python.org/issue38878
diff --git a/Lib/test/test_os.py b/Lib/test/test_os.py
index 4a076e3..11454b2 100644
--- a/Lib/test/test_os.py
+++ b/Lib/test/test_os.py
@@ -4017,6 +4017,14 @@
self.assertRaises(ZeroDivisionError, self.fspath,
FakePath(ZeroDivisionError()))
+ def test_pathlike_subclasshook(self):
+ # bpo-38878: subclasshook causes subclass checks
+ # true on abstract implementation.
+ class A(os.PathLike):
+ pass
+ self.assertFalse(issubclass(FakePath, A))
+ self.assertTrue(issubclass(FakePath, os.PathLike))
+
class TimesTests(unittest.TestCase):
def test_times(self):