Skip to content

Commit e788bb1

Browse files
committed
Add regression test
1 parent ef976c5 commit e788bb1

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

tests/test_lazy_loader.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,17 @@ def test_attach_same_module_and_attr_name(clean_fake_pkg, eager_import):
178178
assert isinstance(some_func, types.FunctionType)
179179

180180

181+
def test_attach_submodule_does_not_shadow_function(clean_fake_pkg):
182+
# Where `some_func` is defined in module `some_func`: When
183+
# submodule is imported before the function has been resolved, the
184+
# import machinery tries to set the package `__dict__` to point to
185+
# the module. We need to prevent this, otherwise we cannot
186+
# access the function.
187+
import tests.fake_pkg.some_func # noqa: F401
188+
from tests import fake_pkg
189+
assert isinstance(fake_pkg.some_func, types.FunctionType)
190+
191+
181192
FAKE_STUB = """
182193
from . import rank
183194
from ._gaussian import gaussian

0 commit comments

Comments
 (0)