Skip to content

Commit 8fdadde

Browse files
committed
Port tests to Python 3.8
1 parent 558f5bf commit 8fdadde

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

importlib_resources/tests/test_functional.py

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
import unittest
22
import os
3+
import contextlib
34

4-
from test.support.warnings_helper import ignore_warnings, check_warnings
5+
try:
6+
from test.support.warnings_helper import ignore_warnings, check_warnings
7+
except ImportError:
8+
# older Python versions
9+
from test.support import ignore_warnings, check_warnings
510

611
import importlib_resources as resources
712

@@ -158,16 +163,17 @@ def test_contents(self):
158163
set(c),
159164
{'utf-8.file', 'utf-16.file', 'binary.file', 'subdirectory'},
160165
)
161-
with (
162-
self.assertRaises(OSError),
163-
check_warnings((".*contents.*", DeprecationWarning)),
164-
):
166+
with contextlib.ExitStack() as cm:
167+
cm.enter_context(self.assertRaises(OSError))
168+
cm.enter_context(check_warnings((".*contents.*", DeprecationWarning)))
169+
165170
list(resources.contents(self.anchor01, 'utf-8.file'))
171+
166172
for path_parts in self._gen_resourcetxt_path_parts():
167-
with (
168-
self.assertRaises(OSError),
169-
check_warnings((".*contents.*", DeprecationWarning)),
170-
):
173+
with contextlib.ExitStack() as cm:
174+
cm.enter_context(self.assertRaises(OSError))
175+
cm.enter_context(check_warnings((".*contents.*", DeprecationWarning)))
176+
171177
list(resources.contents(self.anchor01, *path_parts))
172178
with check_warnings((".*contents.*", DeprecationWarning)):
173179
c = resources.contents(self.anchor01, 'subdirectory')

0 commit comments

Comments
 (0)