mardi 16 janvier 2018

get errors from client post method in django testing

Is there a quick way to get the errors from a form submission when using Client in a django test?

Here's a code snippet:

with open(good_path) as fp:
            data = {
                'account': account_id,
                'date': date,
                'file': fp
            }
            response = client.post(reverse('myapp:form-page'), data)

The page is not redirecting correctly (response=200) and I can see in response.content that there is an error being returned.

Is there a quick way to isolate the error? I was hoping for something like response.errors, similar to a forms instance.

Aucun commentaire:

Enregistrer un commentaire