jeudi 15 juin 2017

Avoiding exception traceback in console output

So I'm testing that a view returns a Http404 exception using assertRaises(Http404) and it works fine. The problem is that my test console output looks like this:

Creating test database for alias 'default'...
Traceback (most recent call last):
  File "/home/dan/aiva/django/aiva/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 147, in get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/home/dan/aiva/django/aiva/local/lib/python2.7/site-packages/django/contrib/auth/decorators.py", line 23, in _wrapped_view
    return view_func(request, *args, **kwargs)
  File "/home/dan/aiva/django/aiva/local/lib/python2.7/site-packages/django/views/generic/base.py", line 68, in view
    return self.dispatch(request, *args, **kwargs)
  File "/home/dan/aiva/django/aiva/local/lib/python2.7/site-packages/django/views/generic/base.py", line 88, in dispatch
    return handler(request, *args, **kwargs)
  File "/home/dan/aiva/django/aiva/local/lib/python2.7/site-packages/django/views/generic/detail.py", line 117, in get
    self.object = self.get_object()
  File "/home/dan/aiva/django/aiva/local/lib/python2.7/site-packages/django/views/generic/detail.py", line 56, in get_object
    {'verbose_name': queryset.model._meta.verbose_name})
Http404: No contact found matching the query
...
----------------------------------------------------------------------
Ran 3 tests in 0.299s

OK
Destroying test database for alias 'default'...

What's a good way to avoid this from happening?

Aucun commentaire:

Enregistrer un commentaire