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
607ff4ef
Kaydet (Commit)
607ff4ef
authored
Nis 15, 2019
tarafından
Carlton Gibson
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Refs #30254 -- Added tests for Model.__hash__() inheritance.
üst
c00b4dbd
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
1 deletion
+18
-1
tests.py
tests/basic/tests.py
+18
-1
No files found.
tests/basic/tests.py
Dosyayı görüntüle @
607ff4ef
...
...
@@ -2,7 +2,7 @@ import threading
from
datetime
import
datetime
,
timedelta
from
django.core.exceptions
import
MultipleObjectsReturned
,
ObjectDoesNotExist
from
django.db
import
DEFAULT_DB_ALIAS
,
DatabaseError
,
connections
from
django.db
import
DEFAULT_DB_ALIAS
,
DatabaseError
,
connections
,
models
from
django.db.models.manager
import
BaseManager
from
django.db.models.query
import
EmptyQuerySet
,
QuerySet
from
django.test
import
(
...
...
@@ -357,6 +357,23 @@ class ModelTest(TestCase):
# hash)
hash
(
Article
())
def
test_missing_hash_not_inherited
(
self
):
class
NoHash
(
models
.
Model
):
def
__eq__
(
self
,
other
):
return
super
.
__eq__
(
other
)
with
self
.
assertRaisesMessage
(
TypeError
,
"unhashable type: 'NoHash'"
):
hash
(
NoHash
(
id
=
1
))
def
test_specified_parent_hash_inherited
(
self
):
class
ParentHash
(
models
.
Model
):
def
__eq__
(
self
,
other
):
return
super
.
__eq__
(
other
)
__hash__
=
models
.
Model
.
__hash__
self
.
assertEqual
(
hash
(
ParentHash
(
id
=
1
)),
1
)
def
test_delete_and_access_field
(
self
):
# Accessing a field after it's deleted from a model reloads its value.
pub_date
=
datetime
.
now
()
...
...
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