We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent b3cd06f commit da1f18aCopy full SHA for da1f18a
benchmarks/form_benchmarks/__init__.py
benchmarks/form_benchmarks/form_validate/__init__.py
benchmarks/form_benchmarks/form_validate/benchmark.py
@@ -0,0 +1,26 @@
1
+from django import forms
2
+from django.core.exceptions import ValidationError
3
+
4
+from ...utils import bench_setup
5
6
7
+def form_validator(title):
8
+ if title != "hi":
9
+ raise ValidationError("title is not hi")
10
11
12
+class BookForm(forms.Form):
13
+ title = forms.CharField(max_length=100, validators=[form_validator])
14
15
16
+class FormValidate:
17
+ def setup(self):
18
+ bench_setup()
19
+ self.form = BookForm({"title": "hi"})
20
+ self.invalid_form = BookForm({"title": "abc"})
21
22
+ def time_form_validate(self):
23
+ self.form.is_valid()
24
25
+ def time_form_invalid(self):
26
+ self.invalid_form.is_valid()
0 commit comments