From 2cec87b8226a3808c3047cb0c8272dac542588f3 Mon Sep 17 00:00:00 2001 From: "Loucky, Jakub" Date: Sat, 16 Mar 2024 10:35:01 -0400 Subject: [PATCH 1/4] Add test capturing missed expectation. Ref #257. --- importlib_resources/tests/test_files.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/importlib_resources/tests/test_files.py b/importlib_resources/tests/test_files.py index 9e45f70..3e86ec6 100644 --- a/importlib_resources/tests/test_files.py +++ b/importlib_resources/tests/test_files.py @@ -34,6 +34,11 @@ def test_read_text(self): def test_traversable(self): assert isinstance(resources.files(self.data), Traversable) + def test_joinpath_with_multiple_args(self): + files = resources.files(self.data) + binfile = files.joinpath('subdirectory', 'binary.file') + self.assertTrue(binfile.is_file()) + def test_old_parameter(self): """ Files used to take a 'package' parameter. Make sure anyone From d7b6cfbf73317aaa69500444811a44c94eb75a95 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sat, 16 Mar 2024 10:38:17 -0400 Subject: [PATCH 2/4] Mark test as xfail on Python 3.10 where it fails. Ref #257. --- importlib_resources/tests/test_files.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/importlib_resources/tests/test_files.py b/importlib_resources/tests/test_files.py index 3e86ec6..1d28179 100644 --- a/importlib_resources/tests/test_files.py +++ b/importlib_resources/tests/test_files.py @@ -4,6 +4,8 @@ import importlib import contextlib +import pytest + import importlib_resources as resources from ..abc import Traversable from . import data01 @@ -34,6 +36,7 @@ def test_read_text(self): def test_traversable(self): assert isinstance(resources.files(self.data), Traversable) + @pytest.mark.xfail("sys.version_info[:2] == (3, 10)", reason="#257") def test_joinpath_with_multiple_args(self): files = resources.files(self.data) binfile = files.joinpath('subdirectory', 'binary.file') From d9e44b65dfb6a51f2ec9ee1e041ff46ca75befef Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sat, 16 Mar 2024 11:01:33 -0400 Subject: [PATCH 3/4] Ensure stdlib readers are excluded on Python 3.10 even when found in importlib.readers. Closes #257. --- importlib_resources/future/adapters.py | 3 ++- importlib_resources/tests/test_files.py | 3 --- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/importlib_resources/future/adapters.py b/importlib_resources/future/adapters.py index 9aa5b5e..9d26bf4 100644 --- a/importlib_resources/future/adapters.py +++ b/importlib_resources/future/adapters.py @@ -24,7 +24,8 @@ def wrapper(*args, **kwargs): # MultiplexedPath may fail on zip subdirectory return # Python 3.10+ - if reader.__class__.__module__.startswith('importlib.resources.'): + mod_name = reader.__class__.__module__ + if mod_name.startswith('importlib.') and mod_name.endswith('readers'): return # Python 3.8, 3.9 if isinstance(reader, _adapters.CompatibilityFiles) and ( diff --git a/importlib_resources/tests/test_files.py b/importlib_resources/tests/test_files.py index 1d28179..3e86ec6 100644 --- a/importlib_resources/tests/test_files.py +++ b/importlib_resources/tests/test_files.py @@ -4,8 +4,6 @@ import importlib import contextlib -import pytest - import importlib_resources as resources from ..abc import Traversable from . import data01 @@ -36,7 +34,6 @@ def test_read_text(self): def test_traversable(self): assert isinstance(resources.files(self.data), Traversable) - @pytest.mark.xfail("sys.version_info[:2] == (3, 10)", reason="#257") def test_joinpath_with_multiple_args(self): files = resources.files(self.data) binfile = files.joinpath('subdirectory', 'binary.file') From ef414edbc74feca0ed1dfa9d00fc3df435eb3169 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sat, 16 Mar 2024 11:02:59 -0400 Subject: [PATCH 4/4] Add news fragment. --- newsfragments/257.bugfix.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 newsfragments/257.bugfix.rst diff --git a/newsfragments/257.bugfix.rst b/newsfragments/257.bugfix.rst new file mode 100644 index 0000000..d8feffd --- /dev/null +++ b/newsfragments/257.bugfix.rst @@ -0,0 +1 @@ +Restored expectation that stdlib readers are suppressed on Python 3.10. \ No newline at end of file