Hi Kenneth,

It looks like the test can't find the /success/ URL
and then tries to display a 404 error, but there is o 404.html template

Do you have 404.html template created?

zalun

On 10-12-15 01:13, Kenneth Gonsalves wrote:
hi,

I am trying to write a test of a view with test client. My test is like
this:

class Testgetnum(unittest.TestCase):
     def setUp(self):
         self.client = Client()
     def testgetnum(self):
         response = self.client.post('/success/',{'id':1})
         self.assertEqual(response.status_code, 200)

but the test crashes since it cannot find the template mentioned in the
view. But the template is there in the correct directory pointed to by
settings. The error traceback is:

Traceback (most recent call
last):
   File "/home/lawgon/addition/../addition/addnums/tests.py", line 38, in
testgetnum
     response =
self.client.post('/success/',{'id':1})
   File "/usr/lib/python2.6/site-packages/django/test/client.py", line
444, in post
     response = super(Client, self).post(path, data=data,
content_type=content_type, **extra)
   File "/usr/lib/python2.6/site-packages/django/test/client.py", line
245, in post
     return
self.request(**r)
   File "/usr/lib/python2.6/site-packages/django/core/handlers/base.py",
line 139, in get_response
     response = callback(request,
**param_dict)
   File "/usr/lib/python2.6/site-packages/django/utils/decorators.py",
line 89, in _wrapped_view
     response = view_func(request, *args,
**kwargs)
   File "/usr/lib/python2.6/site-packages/django/views/defaults.py", line
18, in page_not_found
     t = loader.get_template(template_name) # You need to create a
404.html template.
   File "/usr/lib/python2.6/site-packages/django/template/loader.py",
line 157, in get_template
     template, origin =
find_template(template_name)
   File "/usr/lib/python2.6/site-packages/django/template/loader.py",
line 138, in find_template
     raise
TemplateDoesNotExist(name)
TemplateDoesNotExist: 404.html


--
blog http://piotr.zalewa.info
jobs http://webdev.zalewa.info
twit http://twitter.com/zalun
face http://www.facebook.com/zaloon

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to