class WsgiLogErrorsTest(TestCase): def setUp(self): super(WsgiLogErrorsTest, self).setUp() self.wle = WsgiLogErrors() self.request = Mock() self.request.META = {'wsgi.errors': StringIO()} self.exception = Exception('test exception', 'abc') self.exception404 = Http404('test 404', 'abc') self.exception403 = PermissionDenied('test 403', 'abc') def test_process_exception(self): self.assertEqual(self.request.META['wsgi.errors'].getvalue(), '') response = self.wle.process_exception(self.request, self.exception) self.assertEqual(response, None) self.assertRegexpMatches( self.request.META['wsgi.errors'].getvalue(), "^EXCEPTION raised serving: <Mock name='mock\.build_absolute_uri\(\)' id='\d+'>" ) def test_skip_403(self): self.assertEqual(self.request.META['wsgi.errors'].getvalue(), '') response = self.wle.process_exception(self.request, self.exception403) self.assertEqual(response, None) self.assertEqual(self.request.META['wsgi.errors'].getvalue(), '') def test_skip_404(self): self.assertEqual(self.request.META['wsgi.errors'].getvalue(), '') response = self.wle.process_exception(self.request, self.exception404) self.assertEqual(response, None) self.assertEqual(self.request.META['wsgi.errors'].getvalue(), '')
def setUp(self): super(WsgiLogErrorsTest, self).setUp() self.wle = WsgiLogErrors() self.request = Mock() self.request.META = {'wsgi.errors': StringIO()} self.exception = Exception('test exception', 'abc') self.exception404 = Http404('test 404', 'abc') self.exception403 = PermissionDenied('test 403', 'abc')