dash1291/zamboni — comment on commit fcdf6a46f67c40d4b45ebcd224f4ae1bde83f647
File: apps/api/tests/test_views.py line 195
By cvan:

I'd do something like this, but put the `import`s in the right places:

def test_handler500(self):
from amo.views import handler500
from django.test.client import RequestFactory
from mock import Mock
fake_request = RequestFactory().get('/en-US/firefox/api/')
fake_request.APP = amo.FIREFOX
fake_request.user = Mock()
fake_request.user.is_authenticated.return_value = False
try:
raise NameError('an error')
except NameError:
r = handler500(fake_request)
eq_(r.status_code, 500)
# Test XML, etc.