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
7edd912c
Kaydet (Commit)
7edd912c
authored
Tem 02, 2015
tarafından
Tim Graham
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Used assertRaisesMessage in managers_regress tests.
üst
61f3e22e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
16 deletions
+10
-16
tests.py
tests/managers_regress/tests.py
+10
-16
No files found.
tests/managers_regress/tests.py
Dosyayı görüntüle @
7edd912c
...
...
@@ -66,35 +66,29 @@ class ManagersRegressionTests(TestCase):
def
test_abstract_manager
(
self
):
# Accessing the manager on an abstract model should
# raise an attribute error with an appropriate message.
try
:
# This error message isn't ideal, but if the model is abstract and
# a lot of the class instantiation logic isn't invoked; if the
# manager is implied, then we don't get a hook to install the
# error-raising manager.
msg
=
"type object 'AbstractBase3' has no attribute 'objects'"
with
self
.
assertRaisesMessage
(
AttributeError
,
msg
):
AbstractBase3
.
objects
.
all
()
self
.
fail
(
'Should raise an AttributeError'
)
except
AttributeError
as
e
:
# This error message isn't ideal, but if the model is abstract and
# a lot of the class instantiation logic isn't invoked; if the
# manager is implied, then we don't get a hook to install the
# error-raising manager.
self
.
assertEqual
(
str
(
e
),
"type object 'AbstractBase3' has no attribute 'objects'"
)
def
test_custom_abstract_manager
(
self
):
# Accessing the manager on an abstract model with an custom
# manager should raise an attribute error with an appropriate
# message.
try
:
msg
=
"Manager isn't available; AbstractBase2 is abstract"
with
self
.
assertRaisesMessage
(
AttributeError
,
msg
):
AbstractBase2
.
restricted
.
all
()
self
.
fail
(
'Should raise an AttributeError'
)
except
AttributeError
as
e
:
self
.
assertEqual
(
str
(
e
),
"Manager isn't available; AbstractBase2 is abstract"
)
def
test_explicit_abstract_manager
(
self
):
# Accessing the manager on an abstract model with an explicit
# manager should raise an attribute error with an appropriate
# message.
try
:
msg
=
"Manager isn't available; AbstractBase1 is abstract"
with
self
.
assertRaisesMessage
(
AttributeError
,
msg
):
AbstractBase1
.
objects
.
all
()
self
.
fail
(
'Should raise an AttributeError'
)
except
AttributeError
as
e
:
self
.
assertEqual
(
str
(
e
),
"Manager isn't available; AbstractBase1 is abstract"
)
@override_settings
(
TEST_SWAPPABLE_MODEL
=
'managers_regress.Parent'
)
def
test_swappable_manager
(
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