Skip to content

Commit a3a63b5

Browse files
committed
tests(module_loading): Port tests from django 4.0 w/ touchups
Remove django-specific stuff so they're generic. Use pytest for sys paths. See also: https://github.com/django/django/blob/4.0.4/django/utils/module_loading.py
1 parent 4fb953f commit a3a63b5

12 files changed

+177
-0
lines changed

tests/utils/__init__.py

Whitespace-only changes.

tests/utils/test_module/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class SiteMock:
2+
_registry = {}
3+
4+
5+
site = SiteMock()

tests/utils/test_module/__main__.py

Whitespace-only changes.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from . import site
2+
3+
content = "Another Bad Module"
4+
5+
site._registry.update(
6+
{
7+
"foo": "bar",
8+
}
9+
)
10+
11+
raise Exception("Some random exception.")
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
from . import site
2+
3+
content = "Another Good Module"
4+
5+
site._registry.update(
6+
{
7+
"lorem": "ipsum",
8+
}
9+
)

tests/utils/test_module/bad_module.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import a_package_name_that_does_not_exist # NOQA
2+
3+
content = "Bad Module"

tests/utils/test_module/child_module/__init__.py

Whitespace-only changes.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
content = "Grandchild Module"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
content = "Good Module"

tests/utils/test_module/main_module.py

Whitespace-only changes.

0 commit comments

Comments
 (0)