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
9f7cefd5
Kaydet (Commit)
9f7cefd5
authored
Kas 24, 2012
tarafından
Claude Paroz
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #18417 -- Raised exception when unittest.TestCase is decorated with override_settings
üst
f3a0ecc9
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
10 deletions
+20
-10
utils.py
django/test/utils.py
+5
-1
tests.py
tests/regressiontests/settings_tests/tests.py
+15
-9
No files found.
django/test/utils.py
Dosyayı görüntüle @
9f7cefd5
...
...
@@ -188,7 +188,11 @@ class override_settings(object):
def
__call__
(
self
,
test_func
):
from
django.test
import
TransactionTestCase
if
isinstance
(
test_func
,
type
)
and
issubclass
(
test_func
,
TransactionTestCase
):
if
isinstance
(
test_func
,
type
):
if
not
issubclass
(
test_func
,
TransactionTestCase
):
raise
Exception
(
"Only subclasses of Django TransactionTestCase can be decorated "
"with override_settings"
)
original_pre_setup
=
test_func
.
_pre_setup
original_post_teardown
=
test_func
.
_post_teardown
...
...
tests/regressiontests/settings_tests/tests.py
Dosyayı görüntüle @
9f7cefd5
...
...
@@ -6,6 +6,7 @@ from django.core.exceptions import ImproperlyConfigured
from
django.http
import
HttpRequest
from
django.test
import
TransactionTestCase
,
TestCase
,
signals
from
django.test.utils
import
override_settings
from
django.utils
import
unittest
,
six
@override_settings
(
TEST
=
'override'
)
...
...
@@ -67,11 +68,6 @@ class ClassDecoratedTestCase(ClassDecoratedTestCaseSuper):
self
.
fail
()
class
SettingGetter
(
object
):
def
__init__
(
self
):
self
.
test
=
getattr
(
settings
,
'TEST'
,
'undefined'
)
class
SettingsTests
(
TestCase
):
def
setUp
(
self
):
self
.
testvalue
=
None
...
...
@@ -122,10 +118,20 @@ class SettingsTests(TestCase):
self
.
assertRaises
(
AttributeError
,
getattr
,
settings
,
'TEST'
)
def
test_class_decorator
(
self
):
self
.
assertEqual
(
SettingGetter
()
.
test
,
'undefined'
)
DecoratedSettingGetter
=
override_settings
(
TEST
=
'override'
)(
SettingGetter
)
self
.
assertEqual
(
DecoratedSettingGetter
()
.
test
,
'override'
)
self
.
assertRaises
(
AttributeError
,
getattr
,
settings
,
'TEST'
)
# TransactionTestCase can be decorated by override_settings, but not ut.TestCase
class
TransactionTestCaseSubclass
(
TransactionTestCase
):
pass
class
UnittestTestCaseSubclass
(
unittest
.
TestCase
):
pass
decorated
=
override_settings
(
TEST
=
'override'
)(
TransactionTestCaseSubclass
)
self
.
assertIsInstance
(
decorated
,
type
)
self
.
assertTrue
(
issubclass
(
decorated
,
TransactionTestCase
))
with
six
.
assertRaisesRegex
(
self
,
Exception
,
"Only subclasses of Django TransactionTestCase*"
):
decorated
=
override_settings
(
TEST
=
'override'
)(
UnittestTestCaseSubclass
)
def
test_signal_callback_context_manager
(
self
):
self
.
assertRaises
(
AttributeError
,
getattr
,
settings
,
'TEST'
)
...
...
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