I'd like to simulate requests to my views in Django when I'm writing tests. This is mainly to test the forms. Here's a snippet of a simple test request:
from django.tests import TestCase
class MyTests(TestCase):
def test_forms(self):
response = self.client.post("/my/form/", {'something':'something'})
self.assertEqual(response.status_code, 200) # we get our page back with an error
The page always returns a response of 200 whether there's an form error or not. How can I check that my Form failed and that the particular field (soemthing
) had an error?