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
163236ea
Kaydet (Commit)
163236ea
authored
Mar 03, 2019
tarafından
orlnub123
Kaydeden (comit)
Tim Graham
Mar 05, 2019
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #30234 -- Disallowed non-upper settings in settings.configure().
üst
9681e968
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
2 deletions
+15
-2
__init__.py
django/conf/__init__.py
+3
-1
tests.py
tests/settings_tests/tests.py
+12
-1
No files found.
django/conf/__init__.py
Dosyayı görüntüle @
163236ea
...
...
@@ -104,6 +104,8 @@ class LazySettings(LazyObject):
raise
RuntimeError
(
'Settings already configured.'
)
holder
=
UserSettingsHolder
(
default_settings
)
for
name
,
value
in
options
.
items
():
if
not
name
.
isupper
():
raise
TypeError
(
'Setting
%
r must be uppercase.'
%
name
)
setattr
(
holder
,
name
,
value
)
self
.
_wrapped
=
holder
...
...
@@ -198,7 +200,7 @@ class UserSettingsHolder:
self
.
default_settings
=
default_settings
def
__getattr__
(
self
,
name
):
if
name
in
self
.
_deleted
:
if
n
ot
name
.
isupper
()
or
n
ame
in
self
.
_deleted
:
raise
AttributeError
return
getattr
(
self
.
default_settings
,
name
)
...
...
tests/settings_tests/tests.py
Dosyayı görüntüle @
163236ea
import
os
import
sys
import
unittest
from
types
import
ModuleType
from
types
import
ModuleType
,
SimpleNamespace
from
unittest
import
mock
from
django.conf
import
ENVIRONMENT_VARIABLE
,
LazySettings
,
Settings
,
settings
...
...
@@ -318,6 +318,17 @@ class SettingsTests(SimpleTestCase):
with
self
.
assertRaisesMessage
(
RuntimeError
,
'Settings already configured.'
):
settings
.
configure
()
def
test_nonupper_settings_prohibited_in_configure
(
self
):
s
=
LazySettings
()
with
self
.
assertRaisesMessage
(
TypeError
,
"Setting 'foo' must be uppercase."
):
s
.
configure
(
foo
=
'bar'
)
def
test_nonupper_settings_ignored_in_default_settings
(
self
):
s
=
LazySettings
()
s
.
configure
(
SimpleNamespace
(
foo
=
'bar'
))
with
self
.
assertRaises
(
AttributeError
):
getattr
(
s
,
'foo'
)
@requires_tz_support
@mock.patch
(
'django.conf.global_settings.TIME_ZONE'
,
'test'
)
def
test_incorrect_timezone
(
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