Skip to content

Commit

Permalink
Add test capturing failure when resolving the MultiplexedPath for a n…
Browse files Browse the repository at this point in the history
…amespace package with non-path elements in the path.

Ref #311
  • Loading branch information
jaraco committed Sep 9, 2024
1 parent 4875bc5 commit 47d73b1
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions importlib_resources/tests/test_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import importlib
import contextlib

import pytest

import importlib_resources as resources
from ..abc import Traversable
from . import util
Expand Down Expand Up @@ -60,6 +62,27 @@ class OpenZipTests(FilesTests, util.ZipSetup, unittest.TestCase):
class OpenNamespaceTests(FilesTests, util.DiskSetup, unittest.TestCase):
MODULE = 'namespacedata01'

@pytest.mark.xfail(reason="#311")
def test_non_paths_in_dunder_path(self):
"""
Non-path items in a namespace package's ``__path__`` are ignored.
As reported in python/importlib_resources#311, some tools
like Setuptools, when creating editable packages, will inject
non-paths into a namespace package's ``__path__``, a
sentinel like
``__editable__.sample_namespace-1.0.finder.__path_hook__``
to cause the ``PathEntryFinder`` to be called when searching
for packages. In that case, resources should still be loadable.
"""
import namespacedata01

namespacedata01.__path__.append(
'__editable__.sample_namespace-1.0.finder.__path_hook__'
)

resources.files(namespacedata01)


class OpenNamespaceZipTests(FilesTests, util.ZipSetup, unittest.TestCase):
ZIP_MODULE = 'namespacedata01'
Expand Down

0 comments on commit 47d73b1

Please sign in to comment.