Modified the test case from r15383 to avoid an output inconsistency with KeyError.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@15387 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
7aad3d3fa8
commit
67a2bb6341
|
@ -64,12 +64,12 @@ class ExceptionReporterTests(TestCase):
|
||||||
"A simple exception report can be generated"
|
"A simple exception report can be generated"
|
||||||
try:
|
try:
|
||||||
request = self.rf.get('/test_view/')
|
request = self.rf.get('/test_view/')
|
||||||
raise KeyError("Can't find my keys")
|
raise ValueError("Can't find my keys")
|
||||||
except KeyError:
|
except ValueError:
|
||||||
exc_type, exc_value, tb = sys.exc_info()
|
exc_type, exc_value, tb = sys.exc_info()
|
||||||
reporter = ExceptionReporter(request, exc_type, exc_value, tb)
|
reporter = ExceptionReporter(request, exc_type, exc_value, tb)
|
||||||
html = reporter.get_traceback_html()
|
html = reporter.get_traceback_html()
|
||||||
self.assertIn('<h1>KeyError at /test_view/</h1>', html)
|
self.assertIn('<h1>ValueError at /test_view/</h1>', html)
|
||||||
self.assertIn('<pre class="exception_value">Can't find my keys</pre>', html)
|
self.assertIn('<pre class="exception_value">Can't find my keys</pre>', html)
|
||||||
self.assertIn('<th>Request Method:</th>', html)
|
self.assertIn('<th>Request Method:</th>', html)
|
||||||
self.assertIn('<th>Request URL:</th>', html)
|
self.assertIn('<th>Request URL:</th>', html)
|
||||||
|
@ -82,12 +82,12 @@ class ExceptionReporterTests(TestCase):
|
||||||
def test_no_request(self):
|
def test_no_request(self):
|
||||||
"An exception report can be generated without request"
|
"An exception report can be generated without request"
|
||||||
try:
|
try:
|
||||||
raise KeyError("Can't find my keys")
|
raise ValueError("Can't find my keys")
|
||||||
except KeyError:
|
except ValueError:
|
||||||
exc_type, exc_value, tb = sys.exc_info()
|
exc_type, exc_value, tb = sys.exc_info()
|
||||||
reporter = ExceptionReporter(None, exc_type, exc_value, tb)
|
reporter = ExceptionReporter(None, exc_type, exc_value, tb)
|
||||||
html = reporter.get_traceback_html()
|
html = reporter.get_traceback_html()
|
||||||
self.assertIn('<h1>KeyError</h1>', html)
|
self.assertIn('<h1>ValueError</h1>', html)
|
||||||
self.assertIn('<pre class="exception_value">Can't find my keys</pre>', html)
|
self.assertIn('<pre class="exception_value">Can't find my keys</pre>', html)
|
||||||
self.assertNotIn('<th>Request Method:</th>', html)
|
self.assertNotIn('<th>Request Method:</th>', html)
|
||||||
self.assertNotIn('<th>Request URL:</th>', html)
|
self.assertNotIn('<th>Request URL:</th>', html)
|
||||||
|
|
Loading…
Reference in New Issue