Skip to content

Commit

Permalink
Port tests to Python 3.8
Browse files Browse the repository at this point in the history
  • Loading branch information
encukou committed Mar 21, 2024
1 parent 558f5bf commit 8fdadde
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions importlib_resources/tests/test_functional.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import unittest
import os
import contextlib

from test.support.warnings_helper import ignore_warnings, check_warnings
try:
from test.support.warnings_helper import ignore_warnings, check_warnings
except ImportError:
# older Python versions
from test.support import ignore_warnings, check_warnings

import importlib_resources as resources

Expand Down Expand Up @@ -158,16 +163,17 @@ def test_contents(self):
set(c),
{'utf-8.file', 'utf-16.file', 'binary.file', 'subdirectory'},
)
with (
self.assertRaises(OSError),
check_warnings((".*contents.*", DeprecationWarning)),
):
with contextlib.ExitStack() as cm:
cm.enter_context(self.assertRaises(OSError))
cm.enter_context(check_warnings((".*contents.*", DeprecationWarning)))

list(resources.contents(self.anchor01, 'utf-8.file'))

for path_parts in self._gen_resourcetxt_path_parts():
with (
self.assertRaises(OSError),
check_warnings((".*contents.*", DeprecationWarning)),
):
with contextlib.ExitStack() as cm:
cm.enter_context(self.assertRaises(OSError))
cm.enter_context(check_warnings((".*contents.*", DeprecationWarning)))

list(resources.contents(self.anchor01, *path_parts))
with check_warnings((".*contents.*", DeprecationWarning)):
c = resources.contents(self.anchor01, 'subdirectory')
Expand Down

0 comments on commit 8fdadde

Please sign in to comment.