[Checkins] SVN: zope.exceptions/branches/tseaver-no_2to3/src/zope/exceptions/ Complete coverage for z.e.exceptionformatter.print_exception.
Tres Seaver
cvs-admin at zope.org
Fri Apr 6 19:36:58 UTC 2012
Log message for revision 125028:
Complete coverage for z.e.exceptionformatter.print_exception.
Changed:
U zope.exceptions/branches/tseaver-no_2to3/src/zope/exceptions/exceptionformatter.py
U zope.exceptions/branches/tseaver-no_2to3/src/zope/exceptions/tests/test_exceptionformatter.py
-=-
Modified: zope.exceptions/branches/tseaver-no_2to3/src/zope/exceptions/exceptionformatter.py
===================================================================
--- zope.exceptions/branches/tseaver-no_2to3/src/zope/exceptions/exceptionformatter.py 2012-04-06 19:36:50 UTC (rev 125027)
+++ zope.exceptions/branches/tseaver-no_2to3/src/zope/exceptions/exceptionformatter.py 2012-04-06 19:36:54 UTC (rev 125028)
@@ -263,7 +263,7 @@
information to the traceback and accepts two options, 'as_html'
and 'with_filenames'.
"""
- if file is None:
+ if file is None: #pragma NO COVER
file = sys.stderr
lines = format_exception(t, v, tb, limit, as_html, with_filenames)
for line in lines:
Modified: zope.exceptions/branches/tseaver-no_2to3/src/zope/exceptions/tests/test_exceptionformatter.py
===================================================================
--- zope.exceptions/branches/tseaver-no_2to3/src/zope/exceptions/tests/test_exceptionformatter.py 2012-04-06 19:36:50 UTC (rev 125027)
+++ zope.exceptions/branches/tseaver-no_2to3/src/zope/exceptions/tests/test_exceptionformatter.py 2012-04-06 19:36:54 UTC (rev 125028)
@@ -609,6 +609,41 @@
in s.splitlines()[-1])
+class Test_print_exception(unittest.TestCase):
+
+ def _callFUT(self, as_html=False):
+ from StringIO import StringIO
+ buf = StringIO()
+ import sys
+ from zope.exceptions.exceptionformatter import print_exception
+ t, v, b = sys.exc_info()
+ try:
+ print_exception(t, v, b, file=buf, as_html=as_html)
+ return buf.getvalue()
+ finally:
+ del b
+
+ def test_basic_names_text(self):
+ try:
+ raise ExceptionForTesting
+ except ExceptionForTesting:
+ s = self._callFUT(False)
+ # The traceback should include the name of this function.
+ self.assertTrue(s.find('test_basic_names_text') >= 0)
+ # The traceback should include the name of the exception.
+ self.assertTrue(s.find('ExceptionForTesting') >= 0)
+
+ def test_basic_names_html(self):
+ try:
+ raise ExceptionForTesting
+ except ExceptionForTesting:
+ s = self._callFUT(True)
+ # The traceback should include the name of this function.
+ self.assertTrue(s.find('test_basic_names_html') >= 0)
+ # The traceback should include the name of the exception.
+ self.assertTrue(s.find('ExceptionForTesting') >= 0)
+
+
class Test_extract_stack(unittest.TestCase):
def _callFUT(self, as_html=False):
@@ -749,6 +784,8 @@
def test_suite():
return unittest.TestSuite((
unittest.makeSuite(TextExceptionFormatterTests),
+ unittest.makeSuite(HTMLExceptionFormatterTests),
unittest.makeSuite(Test_format_exception),
+ unittest.makeSuite(Test_print_exception),
unittest.makeSuite(Test_extract_stack),
))
More information about the checkins
mailing list