Django testing, no 404 response when expected -
i writing tests in django check apps have written. more or less working through suggested on here (http://toastdriven.com/blog/2011/apr/10/guide-to-testing-in-django/). however, when put
resp = self.client.get('made_up_url') self.assertequal(resp.status_code, 404)
which doesn't exist (and hence i'm hoping 404 response, i.e. test pass)...but test fails saying 200!=400, i.e. seems think made_up_url valid page.
any ideas wrong?
you trying self.client.get
unexistent url: made_up_url
. dan-klasson told you, need /made_up_url
.
i suggest that, instead of hardcoding url in self.client.get
arguments, first name related url in urls.py
file. can resolve via reverse
function.
then, once have name
it, can in unit tests:
from django.core.urlresolvers import reverse url = reverse('made_up_url') resp = self.client.get(url) self.assertequal(resp.status_code, 404)
Comments
Post a Comment