#33301: Documentation for assertFormError and assertFormsetError doesn't explain
all arguments
-------------------------------------+-------------------------------------
Reporter: Baptiste Mispelon | Owner: Baptiste
Type: | Mispelon
Cleanup/optimization | Status: assigned
Component: Documentation | Version: 3.2
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Baptiste Mispelon):
* owner: nobody => Baptiste Mispelon
* status: new => assigned
* easy: 1 => 0
Comment:
I might have been too quick to mark this as an "easy picking"...
After digging a little, I found that the situation is a bit messier than
I'd seen at first. Several custom `assert...` methods take a response
object as a required argument, but some of them will accept any
`HttpReponse` (and subclasses) whereas some require a response object from
the test client:
||= assert =||= Type of response =||= attribute =||
||
[[https://docs.djangoproject.com/en/dev/topics/testing/tools/#django.test.SimpleTestCase.assertFormError|assertFormError]]
|| Test client || `response.context` ||
||
[[https://docs.djangoproject.com/en/dev/topics/testing/tools/#django.test.SimpleTestCase.assertFormsetError|assertFormsetError]]
|| Test client || `response.context` ||
||
[[https://docs.djangoproject.com/en/dev/topics/testing/tools/#django.test.SimpleTestCase.assertContains|assertContains]]
|| Any || ||
||
[[https://docs.djangoproject.com/en/dev/topics/testing/tools/#django.test.SimpleTestCase.assertNotContains|assertNotContains]]
|| Any || ||
||
[[https://docs.djangoproject.com/en/dev/topics/testing/tools/#django.test.SimpleTestCase.assertTemplateUsed|assertTemplateUsed]]
|| Test client || `response.templates` ||
||
[[https://docs.djangoproject.com/en/dev/topics/testing/tools/#django.test.SimpleTestCase.assertTemplateNotUsed|assertTemplateNotUsed]]
|| Test client || `response.templates` ||
||
[[https://docs.djangoproject.com/en/dev/topics/testing/tools/#django.test.SimpleTestCase.assertRedirects|assertRedirects]]
|| Any || ||
On top of that, while `assertTemplateUsed` (and `assertTemplateNotUsed`)
does specific error checking to alert the user if they're not using a test
client response, `assertFormError` (and `assertFormsetError`) do not and
simply trigger an `AttributeError` if you're passing them the wrong kind
of response.
I'll get started on a proposed fix for all these issue.
--
Ticket URL: <https://code.djangoproject.com/ticket/33301#comment:2>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/067.f6edf6aa816d47af83ddc69ce716fe22%40djangoproject.com.