mirror of
https://github.com/django-components/django-components.git
synced 2025-08-31 11:17:21 +00:00
fix: autoimport with nested apps (#672)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
parent
6b3c112968
commit
ee9b92975a
13 changed files with 218 additions and 112 deletions
|
@ -765,7 +765,7 @@ class MediaRelativePathTests(BaseTestCase):
|
|||
del sys.modules["tests.components.relative_file.relative_file"]
|
||||
|
||||
# Fix the paths, since the "components" dir is nested
|
||||
with autodiscover_with_cleanup(map_module=lambda p: f"tests.{p}"):
|
||||
with autodiscover_with_cleanup(map_module=lambda p: f"tests.{p}" if p.startswith("components") else p):
|
||||
# Make sure that only relevant components are registered:
|
||||
comps_to_remove = [
|
||||
comp_name
|
||||
|
@ -807,7 +807,7 @@ class MediaRelativePathTests(BaseTestCase):
|
|||
del sys.modules["tests.components.relative_file.relative_file"]
|
||||
|
||||
# Fix the paths, since the "components" dir is nested
|
||||
with autodiscover_with_cleanup(map_module=lambda p: f"tests.{p}"):
|
||||
with autodiscover_with_cleanup(map_module=lambda p: f"tests.{p}" if p.startswith("components") else p):
|
||||
registry.unregister("relative_file_pathobj_component")
|
||||
|
||||
template_str: types.django_html = """
|
||||
|
@ -847,7 +847,7 @@ class MediaRelativePathTests(BaseTestCase):
|
|||
del sys.modules["tests.components.relative_file_pathobj.relative_file_pathobj"]
|
||||
|
||||
# Fix the paths, since the "components" dir is nested
|
||||
with autodiscover_with_cleanup(map_module=lambda p: f"tests.{p}"):
|
||||
with autodiscover_with_cleanup(map_module=lambda p: f"tests.{p}" if p.startswith("components") else p):
|
||||
# Mark the PathObj instances of 'relative_file_pathobj_component' so they won raise
|
||||
# error PathObj.__str__ is triggered.
|
||||
CompCls = registry.get("relative_file_pathobj_component")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue