Skip to content

Commit 17879fe

Browse files
barneygalepull[bot]
authored andcommitted
GH-110109: Adjust test_pathlib_abc imports to ease backporting (#113411)
This very boring patch reduces the number of changes needed in `test_pathlib_abc.py` when backporting to the external `pathlib_abc` package.
1 parent 0e2eb2d commit 17879fe

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

Lib/test/test_pathlib/test_pathlib_abc.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,20 @@
22
import io
33
import os
44
import errno
5-
import pathlib
6-
import posixpath
75
import stat
86
import unittest
97

8+
from pathlib._abc import UnsupportedOperation, PurePathBase, PathBase
9+
import posixpath
10+
1011
from test.support import set_recursion_limit
1112
from test.support.os_helper import TESTFN
1213

1314

1415
class UnsupportedOperationTest(unittest.TestCase):
1516
def test_is_notimplemented(self):
16-
self.assertTrue(issubclass(pathlib.UnsupportedOperation, NotImplementedError))
17-
self.assertTrue(isinstance(pathlib.UnsupportedOperation(), NotImplementedError))
17+
self.assertTrue(issubclass(UnsupportedOperation, NotImplementedError))
18+
self.assertTrue(isinstance(UnsupportedOperation(), NotImplementedError))
1819

1920

2021
#
@@ -23,7 +24,7 @@ def test_is_notimplemented(self):
2324

2425

2526
class PurePathBaseTest(unittest.TestCase):
26-
cls = pathlib._abc.PurePathBase
27+
cls = PurePathBase
2728

2829
def test_magic_methods(self):
2930
P = self.cls
@@ -42,7 +43,7 @@ def test_pathmod(self):
4243
self.assertIs(self.cls.pathmod, posixpath)
4344

4445

45-
class DummyPurePath(pathlib._abc.PurePathBase):
46+
class DummyPurePath(PurePathBase):
4647
def __eq__(self, other):
4748
if not isinstance(other, DummyPurePath):
4849
return NotImplemented
@@ -637,12 +638,12 @@ def test_is_relative_to_common(self):
637638
#
638639

639640
class PathBaseTest(PurePathBaseTest):
640-
cls = pathlib._abc.PathBase
641+
cls = PathBase
641642

642643
def test_unsupported_operation(self):
643644
P = self.cls
644645
p = self.cls()
645-
e = pathlib.UnsupportedOperation
646+
e = UnsupportedOperation
646647
self.assertRaises(e, p.stat)
647648
self.assertRaises(e, p.lstat)
648649
self.assertRaises(e, p.exists)
@@ -684,7 +685,7 @@ def test_unsupported_operation(self):
684685
self.assertRaises(e, p.as_uri)
685686

686687
def test_as_uri_common(self):
687-
e = pathlib.UnsupportedOperation
688+
e = UnsupportedOperation
688689
self.assertRaises(e, self.cls().as_uri)
689690

690691
def test_fspath_common(self):
@@ -709,7 +710,7 @@ def close(self):
709710
super().close()
710711

711712

712-
class DummyPath(pathlib._abc.PathBase):
713+
class DummyPath(PathBase):
713714
"""
714715
Simple implementation of PathBase that keeps files and directories in
715716
memory.
@@ -1325,7 +1326,7 @@ def test_readlink(self):
13251326
def test_readlink_unsupported(self):
13261327
P = self.cls(self.base)
13271328
p = P / 'fileA'
1328-
with self.assertRaises(pathlib.UnsupportedOperation):
1329+
with self.assertRaises(UnsupportedOperation):
13291330
q.readlink(p)
13301331

13311332
def _check_resolve(self, p, expected, strict=True):
@@ -1648,7 +1649,7 @@ def _check_complex_symlinks(self, link0_target):
16481649
# Resolve relative paths.
16491650
try:
16501651
self.cls().absolute()
1651-
except pathlib.UnsupportedOperation:
1652+
except UnsupportedOperation:
16521653
return
16531654
old_path = os.getcwd()
16541655
os.chdir(self.base)

0 commit comments

Comments
 (0)