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
aba75b0d
Kaydet (Commit)
aba75b0d
authored
Ara 05, 2013
tarafından
Baptiste Mispelon
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed TypeError when rendering ModelState with multiple bases.
üst
38662d11
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
12 deletions
+38
-12
state.py
django/db/migrations/state.py
+1
-1
test_state.py
tests/migrations/test_state.py
+37
-11
No files found.
django/db/migrations/state.py
Dosyayı görüntüle @
aba75b0d
...
...
@@ -176,7 +176,7 @@ class ModelState(object):
for
base
in
self
.
bases
)
if
None
in
bases
:
raise
InvalidBasesError
(
"Cannot resolve one or more bases from
%
r"
%
self
.
bases
)
raise
InvalidBasesError
(
"Cannot resolve one or more bases from
%
r"
%
(
self
.
bases
,)
)
# Turn fields into a dict for the body, add other bits
body
=
dict
(
self
.
fields
)
body
[
'Meta'
]
=
meta
...
...
tests/migrations/test_state.py
Dosyayı görüntüle @
aba75b0d
...
...
@@ -94,32 +94,58 @@ class StateTests(TestCase):
self
.
assertEqual
(
new_app_cache
.
get_model
(
"migrations"
,
"Tag"
)
.
_meta
.
get_field_by_name
(
"name"
)[
0
]
.
max_length
,
100
)
self
.
assertEqual
(
new_app_cache
.
get_model
(
"migrations"
,
"Tag"
)
.
_meta
.
get_field_by_name
(
"hidden"
)[
0
]
.
null
,
False
)
def
test_render_multiple_inheritance
(
self
):
# Use a custom app cache to avoid polluting the global one.
new_app_cache
=
BaseAppCache
()
def
test_render_model_inheritance
(
self
):
class
Book
(
models
.
Model
):
title
=
models
.
CharField
(
max_length
=
1000
)
class
Meta
:
app_label
=
"migrations"
app_cache
=
new_app_cache
app_cache
=
BaseAppCache
()
class
Novel
(
Book
):
class
Meta
:
app_label
=
"migrations"
app_cache
=
new_app_cache
app_cache
=
BaseAppCache
()
# First, test rendering individually
yet_another_
app_cache
=
BaseAppCache
()
app_cache
=
BaseAppCache
()
# We shouldn't be able to render yet
with
self
.
assertRaises
(
ValueError
):
ModelState
.
from_model
(
Novel
)
.
render
(
yet_another_app_cache
)
ms
=
ModelState
.
from_model
(
Novel
)
with
self
.
assertRaises
(
InvalidBasesError
):
ms
.
render
(
app_cache
)
# Once the parent model is in the app cache, it should be fine
ModelState
.
from_model
(
Book
)
.
render
(
yet_another_app_cache
)
ModelState
.
from_model
(
Novel
)
.
render
(
yet_another_app_cache
)
ModelState
.
from_model
(
Book
)
.
render
(
app_cache
)
ModelState
.
from_model
(
Novel
)
.
render
(
app_cache
)
def
test_render_model_with_multiple_inheritance
(
self
):
class
Foo
(
models
.
Model
):
class
Meta
:
app_label
=
"migrations"
app_cache
=
BaseAppCache
()
class
Bar
(
models
.
Model
):
class
Meta
:
app_label
=
"migrations"
app_cache
=
BaseAppCache
()
class
FooBar
(
Foo
,
Bar
):
class
Meta
:
app_label
=
"migrations"
app_cache
=
BaseAppCache
()
app_cache
=
BaseAppCache
()
# We shouldn't be able to render yet
ms
=
ModelState
.
from_model
(
FooBar
)
with
self
.
assertRaises
(
InvalidBasesError
):
ms
.
render
(
app_cache
)
# Once the parent models are in the app cache, it should be fine
ModelState
.
from_model
(
Foo
)
.
render
(
app_cache
)
ModelState
.
from_model
(
Bar
)
.
render
(
app_cache
)
ModelState
.
from_model
(
FooBar
)
.
render
(
app_cache
)
def
test_render_project_dependencies
(
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