diff options
| author | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2022-04-05 08:37:28 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-04-05 08:37:28 +0200 |
| commit | 1a7d75cf77639e450854d9bcf9518664f755eb04 (patch) | |
| tree | 2e3947e7320daf8b80ad02532dc2daa880dbfe38 /tests/test_client | |
| parent | 78277faafd38d8360efc1fd0c9c52d7bb5eec002 (diff) | |
Moved remaining SimpleTestCase.assertFormError()/assertFormsetErrors() tests to test_utils.
This also removes redundant tests in test_client_regress.
Follow up to 68144f40490b2572c8da4341742b9e387e3f6bdd.
Diffstat (limited to 'tests/test_client')
| -rw-r--r-- | tests/test_client/urls.py | 1 | ||||
| -rw-r--r-- | tests/test_client/views.py | 43 |
2 files changed, 0 insertions, 44 deletions
diff --git a/tests/test_client/urls.py b/tests/test_client/urls.py index 9ccd219fb5..2508346cf8 100644 --- a/tests/test_client/urls.py +++ b/tests/test_client/urls.py @@ -42,7 +42,6 @@ urlpatterns = [ path("bad_view/", views.bad_view), path("form_view/", views.form_view), path("form_view_with_template/", views.form_view_with_template), - path("formset_view/", views.formset_view), path("json_view/", views.json_view), path("login_protected_view/", views.login_protected_view), path("login_protected_method_view/", views.login_protected_method_view), diff --git a/tests/test_client/views.py b/tests/test_client/views.py index 4dc58fab8d..cff0463788 100644 --- a/tests/test_client/views.py +++ b/tests/test_client/views.py @@ -7,7 +7,6 @@ from django.core import mail from django.core.exceptions import ValidationError from django.forms import fields from django.forms.forms import Form -from django.forms.formsets import BaseFormSet, formset_factory from django.http import ( HttpResponse, HttpResponseBadRequest, @@ -259,48 +258,6 @@ def form_view_with_template(request): ) -class BaseTestFormSet(BaseFormSet): - def clean(self): - """No two email addresses are the same.""" - if any(self.errors): - # Don't bother validating the formset unless each form is valid - return - - emails = [] - for form in self.forms: - email = form.cleaned_data["email"] - if email in emails: - raise ValidationError( - "Forms in a set must have distinct email addresses." - ) - emails.append(email) - - -TestFormSet = formset_factory(TestForm, BaseTestFormSet) - - -def formset_view(request): - "A view that tests a simple formset" - if request.method == "POST": - formset = TestFormSet(request.POST) - if formset.is_valid(): - t = Template("Valid POST data.", name="Valid POST Template") - c = Context() - else: - t = Template( - "Invalid POST data. {{ my_formset.errors }}", - name="Invalid POST Template", - ) - c = Context({"my_formset": formset}) - else: - formset = TestForm(request.GET) - t = Template( - "Viewing base formset. {{ my_formset }}.", name="Formset GET Template" - ) - c = Context({"my_formset": formset}) - return HttpResponse(t.render(c)) - - @login_required def login_protected_view(request): "A simple view that is login protected." |
