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
e2e4cdba
Kaydet (Commit)
e2e4cdba
authored
May 01, 2014
tarafından
Yehonatan Daniv
Kaydeden (comit)
Tim Graham
May 01, 2014
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #22539 -- Copied exclude argument in Model.full_clean() to prevent side effects.
üst
45c2d1f5
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
2 deletions
+11
-2
base.py
django/db/models/base.py
+2
-0
__init__.py
tests/validation/__init__.py
+2
-2
tests.py
tests/validation/tests.py
+7
-0
No files found.
django/db/models/base.py
Dosyayı görüntüle @
e2e4cdba
...
@@ -988,6 +988,8 @@ class Model(six.with_metaclass(ModelBase)):
...
@@ -988,6 +988,8 @@ class Model(six.with_metaclass(ModelBase)):
errors
=
{}
errors
=
{}
if
exclude
is
None
:
if
exclude
is
None
:
exclude
=
[]
exclude
=
[]
else
:
exclude
=
list
(
exclude
)
try
:
try
:
self
.
clean_fields
(
exclude
=
exclude
)
self
.
clean_fields
(
exclude
=
exclude
)
...
...
tests/validation/__init__.py
Dosyayı görüntüle @
e2e4cdba
...
@@ -3,9 +3,9 @@ from django.test import TestCase
...
@@ -3,9 +3,9 @@ from django.test import TestCase
class
ValidationTestCase
(
TestCase
):
class
ValidationTestCase
(
TestCase
):
def
assertFailsValidation
(
self
,
clean
,
failed_fields
):
def
assertFailsValidation
(
self
,
clean
,
failed_fields
,
**
kwargs
):
with
self
.
assertRaises
(
ValidationError
)
as
cm
:
with
self
.
assertRaises
(
ValidationError
)
as
cm
:
clean
()
clean
(
**
kwargs
)
self
.
assertEqual
(
sorted
(
failed_fields
),
sorted
(
cm
.
exception
.
message_dict
))
self
.
assertEqual
(
sorted
(
failed_fields
),
sorted
(
cm
.
exception
.
message_dict
))
def
assertFieldFailsValidationWithMessage
(
self
,
clean
,
field_name
,
message
):
def
assertFieldFailsValidationWithMessage
(
self
,
clean
,
field_name
,
message
):
...
...
tests/validation/tests.py
Dosyayı görüntüle @
e2e4cdba
...
@@ -59,6 +59,13 @@ class BaseModelValidationTests(ValidationTestCase):
...
@@ -59,6 +59,13 @@ class BaseModelValidationTests(ValidationTestCase):
mtv
=
ModelToValidate
(
number
=
10
,
name
=
'Some Name'
,
slug
=
'##invalid##'
)
mtv
=
ModelToValidate
(
number
=
10
,
name
=
'Some Name'
,
slug
=
'##invalid##'
)
self
.
assertFailsValidation
(
mtv
.
full_clean
,
[
'slug'
])
self
.
assertFailsValidation
(
mtv
.
full_clean
,
[
'slug'
])
def
test_full_clean_does_not_mutate_exclude
(
self
):
mtv
=
ModelToValidate
(
f_with_custom_validator
=
42
)
exclude
=
[
'number'
]
self
.
assertFailsValidation
(
mtv
.
full_clean
,
[
'name'
],
exclude
=
exclude
)
self
.
assertEqual
(
len
(
exclude
),
1
)
self
.
assertEqual
(
exclude
[
0
],
'number'
)
class
ArticleForm
(
forms
.
ModelForm
):
class
ArticleForm
(
forms
.
ModelForm
):
class
Meta
:
class
Meta
:
...
...
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