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
7ed45606
Kaydet (Commit)
7ed45606
authored
Ara 02, 2016
tarafından
Tim Graham
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Updated LimitChoicesToTests to use setUpTestData and cosmetic edits.
üst
6abd6c59
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
13 deletions
+12
-13
tests.py
tests/model_forms/tests.py
+12
-13
No files found.
tests/model_forms/tests.py
Dosyayı görüntüle @
7ed45606
...
...
@@ -2813,43 +2813,42 @@ class StumpJokeWithCustomFieldForm(forms.ModelForm):
class
Meta
:
model
=
StumpJoke
fields
=
()
# We don't need any fields from the model
fields
=
()
class
LimitChoicesToTest
(
TestCase
):
class
LimitChoicesToTest
s
(
TestCase
):
"""
Tests the functionality of ``limit_choices_to``.
"""
def
setUp
(
self
):
self
.
threepwood
=
Character
.
objects
.
create
(
@classmethod
def
setUpTestData
(
cls
):
cls
.
threepwood
=
Character
.
objects
.
create
(
username
=
'threepwood'
,
last_action
=
datetime
.
datetime
.
today
()
+
datetime
.
timedelta
(
days
=
1
),
)
self
.
marley
=
Character
.
objects
.
create
(
cls
.
marley
=
Character
.
objects
.
create
(
username
=
'marley'
,
last_action
=
datetime
.
datetime
.
today
()
-
datetime
.
timedelta
(
days
=
1
),
)
def
test_limit_choices_to_callable_for_fk_rel
(
self
):
"""
A ForeignKey
relation can use ``limit_choices_to`` as a callable, re #2554
.
A ForeignKey
can use limit_choices_to as a callable (#2554)
.
"""
stumpjokeform
=
StumpJokeForm
()
self
.
assertIn
(
self
.
threepwood
,
stumpjokeform
.
fields
[
'most_recently_fooled'
]
.
queryset
)
self
.
assertNotIn
(
self
.
marley
,
stumpjokeform
.
fields
[
'most_recently_fooled'
]
.
queryset
)
self
.
assertSequenceEqual
(
stumpjokeform
.
fields
[
'most_recently_fooled'
]
.
queryset
,
[
self
.
threepwood
])
def
test_limit_choices_to_callable_for_m2m_rel
(
self
):
"""
A ManyToMany
relation can use ``limit_choices_to`` as a callable, re #2554
.
A ManyToMany
Field can use limit_choices_to as a callable (#2554)
.
"""
stumpjokeform
=
StumpJokeForm
()
self
.
assertIn
(
self
.
threepwood
,
stumpjokeform
.
fields
[
'has_fooled_today'
]
.
queryset
)
self
.
assertNotIn
(
self
.
marley
,
stumpjokeform
.
fields
[
'has_fooled_today'
]
.
queryset
)
self
.
assertSequenceEqual
(
stumpjokeform
.
fields
[
'most_recently_fooled'
]
.
queryset
,
[
self
.
threepwood
])
def
test_custom_field_with_queryset_but_no_limit_choices_to
(
self
):
"""
Regression test for #23795: Make sure a custom field with a `queryset
`
attribute but no `limit_choices_to` still works
.
A custom field with a `queryset` attribute but no `limit_choices_to
`
works (#23795)
.
"""
f
=
StumpJokeWithCustomFieldForm
()
self
.
assertEqual
(
f
.
fields
[
'custom'
]
.
queryset
,
42
)
...
...
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