mirror of
https://github.com/Hopiu/django-rosetta.git
synced 2026-05-12 07:13:10 +00:00
Guess SETTINGS_MODULE is is set to None (in tests)
When testing and using override_settings(), SETTINGS_MODULE is reset, so in case it is set to None, we try to guess it via the DJANGO_SETTINGS_MODULE env var.
This commit is contained in:
parent
7d882990fc
commit
44821f4c88
1 changed files with 8 additions and 2 deletions
|
|
@ -1,5 +1,5 @@
|
|||
from datetime import datetime
|
||||
from django.conf import settings
|
||||
from django.conf import settings, ENVIRONMENT_VARIABLE
|
||||
from rosetta.conf import settings as rosetta_settings
|
||||
import django
|
||||
import os
|
||||
|
|
@ -35,7 +35,13 @@ def find_pos(lang, project_apps=True, django_apps=False, third_party_apps=False)
|
|||
paths = []
|
||||
|
||||
# project/locale
|
||||
parts = settings.SETTINGS_MODULE.split('.')
|
||||
if settings.SETTINGS_MODULE:
|
||||
parts = settings.SETTINGS_MODULE.split('.')
|
||||
else:
|
||||
# if settings.SETTINGS_MODULE is None, we are probably in "test" mode
|
||||
# and override_settings() was used
|
||||
# see: https://code.djangoproject.com/ticket/25911
|
||||
parts = os.environ.get(ENVIRONMENT_VARIABLE).split('.')
|
||||
project = __import__(parts[0], {}, {}, [])
|
||||
abs_project_path = os.path.normpath(os.path.abspath(os.path.dirname(project.__file__)))
|
||||
if project_apps:
|
||||
|
|
|
|||
Loading…
Reference in a new issue