Skip to content

Commit ec6a368

Browse files
committed
fix warnings in test_importlib.test_abc
1 parent d05140f commit ec6a368

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

Lib/test/test_importlib/test_abc.py

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,15 @@ class ResourceLoaderDefaultsTests(ABCTestHarness):
226226
SPLIT = make_abc_subclasses(ResourceLoader)
227227

228228
def test_get_data(self):
229-
with self.assertRaises(IOError):
229+
with (
230+
self.assertRaises(IOError),
231+
self.assertWarnsRegex(
232+
DeprecationWarning,
233+
r"importlib\.abc\.ResourceLoader is deprecated in favour of "
234+
r"supporting resource loading through importlib\.resources"
235+
r"\.abc\.TraversableResources.",
236+
),
237+
):
230238
self.ins.get_data('/some/path')
231239

232240

@@ -927,9 +935,19 @@ def get_filename(self, fullname):
927935

928936
def path_stats(self, path):
929937
return {'mtime': 1}
930-
931-
loader = DummySourceLoader()
932-
with self.assertWarns(DeprecationWarning):
938+
with self.assertWarnsRegex(
939+
DeprecationWarning,
940+
r"importlib\.abc\.ResourceLoader is deprecated in favour of "
941+
r"supporting resource loading through importlib\.resources"
942+
r"\.abc\.TraversableResources.",
943+
):
944+
loader = DummySourceLoader()
945+
946+
with self.assertWarnsRegex(
947+
DeprecationWarning,
948+
r"SourceLoader\.path_mtime is deprecated in favour of "
949+
r"SourceLoader\.path_stats\(\)\."
950+
):
933951
loader.path_mtime('foo.py')
934952

935953

0 commit comments

Comments
 (0)