10
10
class MultiplexedPathTest (unittest .TestCase ):
11
11
@classmethod
12
12
def setUpClass (cls ):
13
- path = pathlib .Path (__file__ ).parent / 'namespacedata01'
14
- cls .folder = str (path )
13
+ cls .folder = pathlib .Path (__file__ ).parent / 'namespacedata01'
15
14
16
15
def test_init_no_paths (self ):
17
16
with self .assertRaises (FileNotFoundError ):
18
17
MultiplexedPath ()
19
18
20
19
def test_init_file (self ):
21
20
with self .assertRaises (NotADirectoryError ):
22
- MultiplexedPath (os . path . join ( self .folder , 'binary.file' ) )
21
+ MultiplexedPath (self .folder / 'binary.file' )
23
22
24
23
def test_iterdir (self ):
25
24
contents = {path .name for path in MultiplexedPath (self .folder ).iterdir ()}
@@ -30,7 +29,7 @@ def test_iterdir(self):
30
29
self .assertEqual (contents , {'binary.file' , 'utf-16.file' , 'utf-8.file' })
31
30
32
31
def test_iterdir_duplicate (self ):
33
- data01 = os . path . abspath ( os . path . join ( __file__ , '..' , ' data01') )
32
+ data01 = pathlib . Path ( __file__ ). parent . joinpath ( ' data01' )
34
33
contents = {
35
34
path .name for path in MultiplexedPath (self .folder , data01 ).iterdir ()
36
35
}
@@ -60,8 +59,8 @@ def test_open_file(self):
60
59
path .open ()
61
60
62
61
def test_join_path (self ):
63
- prefix = os . path . abspath ( os . path . join ( __file__ , '..' ) )
64
- data01 = os . path . join ( prefix , ' data01' )
62
+ data01 = pathlib . Path ( __file__ ). parent . joinpath ( 'data01' )
63
+ prefix = str ( data01 . parent )
65
64
path = MultiplexedPath (self .folder , data01 )
66
65
self .assertEqual (
67
66
str (path .joinpath ('binary.file' ))[len (prefix ) + 1 :],
@@ -82,9 +81,9 @@ def test_join_path_compound(self):
82
81
assert not path .joinpath ('imaginary/foo.py' ).exists ()
83
82
84
83
def test_join_path_common_subdir (self ):
85
- prefix = os . path . abspath ( os . path . join ( __file__ , '..' ) )
86
- data01 = os . path . join ( prefix , 'data01 ' )
87
- data02 = os . path . join ( prefix , 'data02' )
84
+ data01 = pathlib . Path ( __file__ ). parent . joinpath ( 'data01' )
85
+ data02 = pathlib . Path ( __file__ ). parent . joinpath ( 'data02 ' )
86
+ prefix = str ( data01 . parent )
88
87
path = MultiplexedPath (data01 , data02 )
89
88
self .assertIsInstance (path .joinpath ('subdirectory' ), MultiplexedPath )
90
89
self .assertEqual (
0 commit comments