Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
D
django
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
django
Commits
c91dcd36
Kaydet (Commit)
c91dcd36
authored
Tem 27, 2017
tarafından
Anton Samarchyan
Kaydeden (comit)
Tim Graham
Tem 27, 2017
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Improved test coverage for django.conf.
üst
0eefda49
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
0 deletions
+38
-0
tests.py
tests/settings_tests/tests.py
+38
-0
No files found.
tests/settings_tests/tests.py
Dosyayı görüntüle @
c91dcd36
...
...
@@ -3,6 +3,7 @@ import sys
import
unittest
import
warnings
from
types
import
ModuleType
from
unittest
import
mock
from
django.conf
import
ENVIRONMENT_VARIABLE
,
LazySettings
,
Settings
,
settings
from
django.core.exceptions
import
ImproperlyConfigured
...
...
@@ -11,6 +12,7 @@ from django.test import (
SimpleTestCase
,
TestCase
,
TransactionTestCase
,
modify_settings
,
override_settings
,
signals
,
)
from
django.test.utils
import
requires_tz_support
@modify_settings
(
ITEMS
=
{
...
...
@@ -286,6 +288,42 @@ class SettingsTests(SimpleTestCase):
with
self
.
assertRaises
(
AttributeError
):
getattr
(
settings
,
'TEST2'
)
def
test_no_secret_key
(
self
):
settings_module
=
ModuleType
(
'fake_settings_module'
)
sys
.
modules
[
'fake_settings_module'
]
=
settings_module
msg
=
'The SECRET_KEY setting must not be empty.'
try
:
with
self
.
assertRaisesMessage
(
ImproperlyConfigured
,
msg
):
Settings
(
'fake_settings_module'
)
finally
:
del
sys
.
modules
[
'fake_settings_module'
]
def
test_no_settings_module
(
self
):
msg
=
(
'Requested setting
%
s, but settings are not configured. You '
'must either define the environment variable DJANGO_SETTINGS_MODULE '
'or call settings.configure() before accessing settings.'
)
orig_settings
=
os
.
environ
[
ENVIRONMENT_VARIABLE
]
os
.
environ
[
ENVIRONMENT_VARIABLE
]
=
''
try
:
with
self
.
assertRaisesMessage
(
ImproperlyConfigured
,
msg
%
's'
):
settings
.
_setup
()
with
self
.
assertRaisesMessage
(
ImproperlyConfigured
,
msg
%
' TEST'
):
settings
.
_setup
(
'TEST'
)
finally
:
os
.
environ
[
ENVIRONMENT_VARIABLE
]
=
orig_settings
def
test_already_configured
(
self
):
with
self
.
assertRaisesMessage
(
RuntimeError
,
'Settings already configured.'
):
settings
.
configure
()
@requires_tz_support
@mock.patch
(
'django.conf.global_settings.TIME_ZONE'
,
'test'
)
def
test_incorrect_timezone
(
self
):
with
self
.
assertRaisesMessage
(
ValueError
,
'Incorrect timezone setting: test'
):
settings
.
_setup
()
class
TestComplexSettingOverride
(
SimpleTestCase
):
def
setUp
(
self
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment