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
9c40f01a
Kaydet (Commit)
9c40f01a
authored
Tem 28, 2015
tarafından
Keryn Knight
Kaydeden (comit)
Tim Graham
Agu 31, 2015
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Refs #24121 -- Added repr() to LazySettings, Settings, and UserSettingsHolder.
üst
123984ff
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
1 deletion
+45
-1
__init__.py
django/conf/__init__.py
+19
-0
tests.py
tests/settings_tests/tests.py
+26
-1
No files found.
django/conf/__init__.py
Dosyayı görüntüle @
9c40f01a
...
...
@@ -42,6 +42,14 @@ class LazySettings(LazyObject):
self
.
_wrapped
=
Settings
(
settings_module
)
def
__repr__
(
self
):
# Hardcode the class name as otherwise it yields 'Settings'.
if
self
.
_wrapped
is
empty
:
return
'<LazySettings [Unevaluated]>'
return
'<LazySettings "
%(settings_module)
s">'
%
{
'settings_module'
:
self
.
_wrapped
.
SETTINGS_MODULE
,
}
def
__getattr__
(
self
,
name
):
if
self
.
_wrapped
is
empty
:
self
.
_setup
(
name
)
...
...
@@ -136,6 +144,12 @@ class Settings(BaseSettings):
def
is_overridden
(
self
,
setting
):
return
setting
in
self
.
_explicit_settings
def
__repr__
(
self
):
return
'<
%(cls)
s "
%(settings_module)
s">'
%
{
'cls'
:
self
.
__class__
.
__name__
,
'settings_module'
:
self
.
SETTINGS_MODULE
,
}
class
UserSettingsHolder
(
BaseSettings
):
"""
...
...
@@ -176,4 +190,9 @@ class UserSettingsHolder(BaseSettings):
set_on_default
=
getattr
(
self
.
default_settings
,
'is_overridden'
,
lambda
s
:
False
)(
setting
)
return
(
deleted
or
set_locally
or
set_on_default
)
def
__repr__
(
self
):
return
'<
%(cls)
s>'
%
{
'cls'
:
self
.
__class__
.
__name__
,
}
settings
=
LazySettings
()
tests/settings_tests/tests.py
Dosyayı görüntüle @
9c40f01a
...
...
@@ -4,7 +4,7 @@ import unittest
import
warnings
from
types
import
ModuleType
from
django.conf
import
LazySettings
,
Settings
,
settings
from
django.conf
import
ENVIRONMENT_VARIABLE
,
LazySettings
,
Settings
,
settings
from
django.core.exceptions
import
ImproperlyConfigured
from
django.http
import
HttpRequest
from
django.test
import
(
...
...
@@ -442,6 +442,31 @@ class IsOverriddenTest(SimpleTestCase):
with
override_settings
(
ALLOWED_HOSTS
=
[]):
self
.
assertTrue
(
settings
.
is_overridden
(
'ALLOWED_HOSTS'
))
def
test_unevaluated_lazysettings_repr
(
self
):
lazy_settings
=
LazySettings
()
expected
=
'<LazySettings [Unevaluated]>'
self
.
assertEqual
(
repr
(
lazy_settings
),
expected
)
def
test_evaluated_lazysettings_repr
(
self
):
lazy_settings
=
LazySettings
()
module
=
os
.
environ
.
get
(
ENVIRONMENT_VARIABLE
)
expected
=
'<LazySettings "
%
s">'
%
module
# Force evaluation of the lazy object.
lazy_settings
.
APPEND_SLASH
self
.
assertEqual
(
repr
(
lazy_settings
),
expected
)
def
test_usersettingsholder_repr
(
self
):
lazy_settings
=
LazySettings
()
lazy_settings
.
configure
(
APPEND_SLASH
=
False
)
expected
=
'<UserSettingsHolder>'
self
.
assertEqual
(
repr
(
lazy_settings
.
_wrapped
),
expected
)
def
test_settings_repr
(
self
):
module
=
os
.
environ
.
get
(
ENVIRONMENT_VARIABLE
)
lazy_settings
=
Settings
(
module
)
expected
=
'<Settings "
%
s">'
%
module
self
.
assertEqual
(
repr
(
lazy_settings
),
expected
)
class
TestListSettings
(
unittest
.
TestCase
):
"""
...
...
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