diff options
author | Barney Gale <barney.gale@gmail.com> | 2023-07-19 17:59:55 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-19 17:59:55 (GMT) |
commit | c6c5665ee0c0a5ddc96da255c9a62daa332c32b3 (patch) | |
tree | ae67a581c9c4d9fcfcc90b505a0492baae18c6d4 /Lib/test/test_pathlib.py | |
parent | a1a3193990cd6658c1fe859b88a2bc03971a16df (diff) | |
download | cpython-c6c5665ee0c0a5ddc96da255c9a62daa332c32b3.zip cpython-c6c5665ee0c0a5ddc96da255c9a62daa332c32b3.tar.gz cpython-c6c5665ee0c0a5ddc96da255c9a62daa332c32b3.tar.bz2 |
GH-100502: Add `pathlib.PurePath.pathmod` attribute (GH-106533)
This instance attribute stores the implementation of `os.path` used for
low-level path operations: either `posixpath` or `ntpath`.
Diffstat (limited to 'Lib/test/test_pathlib.py')
-rw-r--r-- | Lib/test/test_pathlib.py | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/Lib/test/test_pathlib.py b/Lib/test/test_pathlib.py index eb2b0cf..78948e3 100644 --- a/Lib/test/test_pathlib.py +++ b/Lib/test/test_pathlib.py @@ -66,9 +66,9 @@ class PurePathTest(unittest.TestCase): def setUp(self): p = self.cls('a') - self.flavour = p._flavour - self.sep = self.flavour.sep - self.altsep = self.flavour.altsep + self.pathmod = p.pathmod + self.sep = self.pathmod.sep + self.altsep = self.pathmod.altsep def test_constructor_common(self): P = self.cls @@ -93,17 +93,17 @@ class PurePathTest(unittest.TestCase): p = self.cls('a') self.assertIs(type(p), expected) - def test_different_flavours_unequal(self): + def test_different_pathmods_unequal(self): p = self.cls('a') - if p._flavour is posixpath: + if p.pathmod is posixpath: q = pathlib.PureWindowsPath('a') else: q = pathlib.PurePosixPath('a') self.assertNotEqual(p, q) - def test_different_flavours_unordered(self): + def test_different_pathmods_unordered(self): p = self.cls('a') - if p._flavour is posixpath: + if p.pathmod is posixpath: q = pathlib.PureWindowsPath('a') else: q = pathlib.PurePosixPath('a') @@ -188,16 +188,16 @@ class PurePathTest(unittest.TestCase): return path.drive, path.root, path.parts def _check_drive_root_parts(self, arg, *expected): - sep = self.flavour.sep + sep = self.pathmod.sep actual = self._get_drive_root_parts([x.replace('/', sep) for x in arg]) self.assertEqual(actual, expected) - if altsep := self.flavour.altsep: + if altsep := self.pathmod.altsep: actual = self._get_drive_root_parts([x.replace('/', altsep) for x in arg]) self.assertEqual(actual, expected) def test_drive_root_parts_common(self): check = self._check_drive_root_parts - sep = self.flavour.sep + sep = self.pathmod.sep # Unanchored parts. check((), '', '', ()) check(('a',), '', '', ('a',)) @@ -657,7 +657,7 @@ class PurePathTest(unittest.TestCase): self.assertRaises(ValueError, P('a/b').with_suffix, './.d') self.assertRaises(ValueError, P('a/b').with_suffix, '.d/.') self.assertRaises(ValueError, P('a/b').with_suffix, - (self.flavour.sep, 'd')) + (self.pathmod.sep, 'd')) def test_relative_to_common(self): P = self.cls @@ -2392,8 +2392,8 @@ class PathTest(unittest.TestCase): p = self.cls('a') self.assertIs(type(p), expected) - def test_unsupported_flavour(self): - if self.cls._flavour is os.path: + def test_unsupported_pathmod(self): + if self.cls.pathmod is os.path: self.skipTest("path flavour is supported") else: self.assertRaises(pathlib.UnsupportedOperation, self.cls) @@ -2848,9 +2848,9 @@ class PathTest(unittest.TestCase): def test_is_junction(self): P = self.cls(BASE) - with mock.patch.object(P._flavour, 'isjunction'): - self.assertEqual(P.is_junction(), P._flavour.isjunction.return_value) - P._flavour.isjunction.assert_called_once_with(P) + with mock.patch.object(P.pathmod, 'isjunction'): + self.assertEqual(P.is_junction(), P.pathmod.isjunction.return_value) + P.pathmod.isjunction.assert_called_once_with(P) @unittest.skipUnless(hasattr(os, "mkfifo"), "os.mkfifo() required") @unittest.skipIf(sys.platform == "vxworks", |