2
2
import io
3
3
import os
4
4
import errno
5
- import pathlib
6
- import posixpath
7
5
import stat
8
6
import unittest
9
7
8
+ from pathlib ._abc import UnsupportedOperation , PurePathBase , PathBase
9
+ import posixpath
10
+
10
11
from test .support import set_recursion_limit
11
12
from test .support .os_helper import TESTFN
12
13
13
14
14
15
class UnsupportedOperationTest (unittest .TestCase ):
15
16
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 ))
18
19
19
20
20
21
#
@@ -23,7 +24,7 @@ def test_is_notimplemented(self):
23
24
24
25
25
26
class PurePathBaseTest (unittest .TestCase ):
26
- cls = pathlib . _abc . PurePathBase
27
+ cls = PurePathBase
27
28
28
29
def test_magic_methods (self ):
29
30
P = self .cls
@@ -42,7 +43,7 @@ def test_pathmod(self):
42
43
self .assertIs (self .cls .pathmod , posixpath )
43
44
44
45
45
- class DummyPurePath (pathlib . _abc . PurePathBase ):
46
+ class DummyPurePath (PurePathBase ):
46
47
def __eq__ (self , other ):
47
48
if not isinstance (other , DummyPurePath ):
48
49
return NotImplemented
@@ -637,12 +638,12 @@ def test_is_relative_to_common(self):
637
638
#
638
639
639
640
class PathBaseTest (PurePathBaseTest ):
640
- cls = pathlib . _abc . PathBase
641
+ cls = PathBase
641
642
642
643
def test_unsupported_operation (self ):
643
644
P = self .cls
644
645
p = self .cls ()
645
- e = pathlib . UnsupportedOperation
646
+ e = UnsupportedOperation
646
647
self .assertRaises (e , p .stat )
647
648
self .assertRaises (e , p .lstat )
648
649
self .assertRaises (e , p .exists )
@@ -684,7 +685,7 @@ def test_unsupported_operation(self):
684
685
self .assertRaises (e , p .as_uri )
685
686
686
687
def test_as_uri_common (self ):
687
- e = pathlib . UnsupportedOperation
688
+ e = UnsupportedOperation
688
689
self .assertRaises (e , self .cls ().as_uri )
689
690
690
691
def test_fspath_common (self ):
@@ -709,7 +710,7 @@ def close(self):
709
710
super ().close ()
710
711
711
712
712
- class DummyPath (pathlib . _abc . PathBase ):
713
+ class DummyPath (PathBase ):
713
714
"""
714
715
Simple implementation of PathBase that keeps files and directories in
715
716
memory.
@@ -1325,7 +1326,7 @@ def test_readlink(self):
1325
1326
def test_readlink_unsupported (self ):
1326
1327
P = self .cls (self .base )
1327
1328
p = P / 'fileA'
1328
- with self .assertRaises (pathlib . UnsupportedOperation ):
1329
+ with self .assertRaises (UnsupportedOperation ):
1329
1330
q .readlink (p )
1330
1331
1331
1332
def _check_resolve (self , p , expected , strict = True ):
@@ -1648,7 +1649,7 @@ def _check_complex_symlinks(self, link0_target):
1648
1649
# Resolve relative paths.
1649
1650
try :
1650
1651
self .cls ().absolute ()
1651
- except pathlib . UnsupportedOperation :
1652
+ except UnsupportedOperation :
1652
1653
return
1653
1654
old_path = os .getcwd ()
1654
1655
os .chdir (self .base )
0 commit comments