Changeset View
Changeset View
Standalone View
Standalone View
swh/web/tests/conftest.py
Show First 20 Lines • Show All 1,220 Lines • ▼ Show 20 Lines | def mailmap_user(): | ||||
mailmap_user.user_permissions.add(create_django_permission(MAILMAP_PERMISSION)) | mailmap_user.user_permissions.add(create_django_permission(MAILMAP_PERMISSION)) | ||||
return mailmap_user | return mailmap_user | ||||
def reload_urlconf(): | def reload_urlconf(): | ||||
from django.conf import settings | from django.conf import settings | ||||
clear_url_caches() | clear_url_caches() | ||||
urlconf = settings.ROOT_URLCONF | # force reloading of all URLs as they depend on django settings | ||||
# and swh-web configuration | |||||
urlconfs = [settings.ROOT_URLCONF] | |||||
urlconfs += [f"{app}.urls" for app in settings.SWH_DJANGO_APPS] | |||||
for urlconf in urlconfs: | |||||
try: | |||||
if urlconf in sys.modules: | if urlconf in sys.modules: | ||||
reload(sys.modules[urlconf]) | reload(sys.modules[urlconf]) | ||||
else: | else: | ||||
import_module(urlconf) | import_module(urlconf) | ||||
except ModuleNotFoundError: | |||||
pass | |||||
class SwhSettingsWrapper(SettingsWrapper): | class SwhSettingsWrapper(SettingsWrapper): | ||||
def __setattr__(self, attr: str, value) -> None: | def __setattr__(self, attr: str, value) -> None: | ||||
super().__setattr__(attr, value) | super().__setattr__(attr, value) | ||||
reload_urlconf() | reload_urlconf() | ||||
def finalize(self) -> None: | def finalize(self) -> None: | ||||
Show All 13 Lines |