DataGreed DataGreed - 9 months ago 71
Python Question

Django - testing pages for 500 status

I've got a project where some changes may lead to 500 status in some views.

What is the most elegant way to make unit tests that will check all the views/pages (with static routes, without vars in them, of course) for not returning 500 status?


For unit tests you can use something like:

from django import test
from django.core.urlresolvers import reverse
from page.urls import urlpatterns

class PageTest(test.TestCase):

   def test_responses(self):
       for url in urlpatterns:
           response = self.client.get(reverse(
           self.assertEqual(response.status_code, 200)