Skip to content

Commit f004f04

Browse files
committed
Update tests for MultiplexedPath to pass traversables, addressing some deprecation warnings.
1 parent c02bc7e commit f004f04

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

importlib_resources/tests/test_reader.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,15 @@
1010
class MultiplexedPathTest(unittest.TestCase):
1111
@classmethod
1212
def setUpClass(cls):
13-
path = pathlib.Path(__file__).parent / 'namespacedata01'
14-
cls.folder = str(path)
13+
cls.folder = pathlib.Path(__file__).parent / 'namespacedata01'
1514

1615
def test_init_no_paths(self):
1716
with self.assertRaises(FileNotFoundError):
1817
MultiplexedPath()
1918

2019
def test_init_file(self):
2120
with self.assertRaises(NotADirectoryError):
22-
MultiplexedPath(os.path.join(self.folder, 'binary.file'))
21+
MultiplexedPath(self.folder / 'binary.file')
2322

2423
def test_iterdir(self):
2524
contents = {path.name for path in MultiplexedPath(self.folder).iterdir()}
@@ -30,7 +29,7 @@ def test_iterdir(self):
3029
self.assertEqual(contents, {'binary.file', 'utf-16.file', 'utf-8.file'})
3130

3231
def test_iterdir_duplicate(self):
33-
data01 = os.path.abspath(os.path.join(__file__, '..', 'data01'))
32+
data01 = pathlib.Path(__file__).parent.joinpath('data01')
3433
contents = {
3534
path.name for path in MultiplexedPath(self.folder, data01).iterdir()
3635
}
@@ -60,8 +59,8 @@ def test_open_file(self):
6059
path.open()
6160

6261
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)
6564
path = MultiplexedPath(self.folder, data01)
6665
self.assertEqual(
6766
str(path.joinpath('binary.file'))[len(prefix) + 1 :],
@@ -82,9 +81,9 @@ def test_join_path_compound(self):
8281
assert not path.joinpath('imaginary/foo.py').exists()
8382

8483
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)
8887
path = MultiplexedPath(data01, data02)
8988
self.assertIsInstance(path.joinpath('subdirectory'), MultiplexedPath)
9089
self.assertEqual(

0 commit comments

Comments
 (0)