mirror of
https://github.com/jazzband/django-configurations.git
synced 2026-03-16 22:20:27 +00:00
Fix check_options of ConfigurationImporter
This commit is contained in:
parent
52c679e676
commit
275a5b409a
2 changed files with 16 additions and 1 deletions
|
|
@ -95,9 +95,9 @@ class ConfigurationImporter(object):
|
|||
|
||||
def __init__(self, check_options=False):
|
||||
self.argv = sys.argv[:]
|
||||
self.validate()
|
||||
if check_options:
|
||||
self.check_options()
|
||||
self.validate()
|
||||
|
||||
def __repr__(self):
|
||||
return "<ConfigurationImporter for '{0}.{1}'>".format(self.module,
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import os
|
||||
import sys
|
||||
|
||||
from django.conf import global_settings
|
||||
from django.test import TestCase
|
||||
|
|
@ -78,3 +79,17 @@ class MainTests(TestCase):
|
|||
self.assertEqual(importer.module,
|
||||
'tests.settings.inheritance')
|
||||
self.assertEqual(importer.name, 'Inheritance')
|
||||
|
||||
@patch.dict(os.environ, clear=True,
|
||||
DJANGO_SETTINGS_MODULE='tests.settings.main',
|
||||
DJANGO_CONFIGURATION='NonExisting')
|
||||
@patch.object(sys, 'argv', ['python', 'manage.py', 'test',
|
||||
'--settings=tests.settings.main',
|
||||
'--configuration=Test'])
|
||||
def test_configuration_option(self):
|
||||
importer = ConfigurationImporter(check_options=False)
|
||||
self.assertEqual(importer.module, 'tests.settings.main')
|
||||
self.assertEqual(importer.name, 'NonExisting')
|
||||
importer = ConfigurationImporter(check_options=True)
|
||||
self.assertEqual(importer.module, 'tests.settings.main')
|
||||
self.assertEqual(importer.name, 'Test')
|
||||
|
|
|
|||
Loading…
Reference in a new issue