Fix issue #368 and add tests (#369)

This commit is contained in:
Dylan Castillo 2024-01-27 23:10:03 +01:00 committed by GitHub
parent 997ed52bb6
commit dc9f1b46b2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 106 additions and 9 deletions

View file

@ -0,0 +1,30 @@
from django.urls import include, path
# isort: off
from .django_test_setup import * # noqa
from .testutils import Django30CompatibleSimpleTestCase as SimpleTestCase
# isort: on
from django_components import autodiscover, component
urlpatterns = [
path("", include("tests.components.urls")),
]
class TestAutodiscover(SimpleTestCase):
def setUp(self):
settings.SETTINGS_MODULE = "tests.test_autodiscover" # noqa
def tearDown(self) -> None:
del settings.SETTINGS_MODULE # noqa
def test_autodiscover_with_components_as_views(self):
try:
autodiscover()
except component.AlreadyRegistered:
self.fail(
"Autodiscover should not raise AlreadyRegistered exception"
)