summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_pathlib/test_pathlib_abc.py
diff options
context:
space:
mode:
authorBarney Gale <barney.gale@gmail.com>2024-01-31 00:59:33 (GMT)
committerGitHub <noreply@github.com>2024-01-31 00:59:33 (GMT)
commit574291963f6b0eb7da3fde1ae9763236e7ece306 (patch)
tree54639605dc0db7b2e69c0b54527ca939a9acaa4d /Lib/test/test_pathlib/test_pathlib_abc.py
parent1667c2868633a1091b3519594103ca7662d64d75 (diff)
downloadcpython-574291963f6b0eb7da3fde1ae9763236e7ece306.zip
cpython-574291963f6b0eb7da3fde1ae9763236e7ece306.tar.gz
cpython-574291963f6b0eb7da3fde1ae9763236e7ece306.tar.bz2
pathlib ABCs: drop partial, broken, untested support for `bytes` paths. (#114777)
Methods like `full_match()`, `glob()`, etc, are difficult to make work with byte paths, and it's not worth the effort. This patch makes `PurePathBase` raise `TypeError` when given non-`str` path segments.
Diffstat (limited to 'Lib/test/test_pathlib/test_pathlib_abc.py')
-rw-r--r--Lib/test/test_pathlib/test_pathlib_abc.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/Lib/test/test_pathlib/test_pathlib_abc.py b/Lib/test/test_pathlib/test_pathlib_abc.py
index 0e12182..207579c 100644
--- a/Lib/test/test_pathlib/test_pathlib_abc.py
+++ b/Lib/test/test_pathlib/test_pathlib_abc.py
@@ -155,6 +155,31 @@ class DummyPurePathTest(unittest.TestCase):
P('a/b/c')
P('/a/b/c')
+ def test_bytes(self):
+ P = self.cls
+ with self.assertRaises(TypeError):
+ P(b'a')
+ with self.assertRaises(TypeError):
+ P(b'a', 'b')
+ with self.assertRaises(TypeError):
+ P('a', b'b')
+ with self.assertRaises(TypeError):
+ P('a').joinpath(b'b')
+ with self.assertRaises(TypeError):
+ P('a') / b'b'
+ with self.assertRaises(TypeError):
+ b'a' / P('b')
+ with self.assertRaises(TypeError):
+ P('a').match(b'b')
+ with self.assertRaises(TypeError):
+ P('a').relative_to(b'b')
+ with self.assertRaises(TypeError):
+ P('a').with_name(b'b')
+ with self.assertRaises(TypeError):
+ P('a').with_stem(b'b')
+ with self.assertRaises(TypeError):
+ P('a').with_suffix(b'b')
+
def _check_str_subclass(self, *args):
# Issue #21127: it should be possible to construct a PurePath object
# from a str subclass instance, and it then gets converted to