Skip to content

Instantly share code, notes, and snippets.

@ironpythonbot
Created December 9, 2014 18:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ironpythonbot/e5a4a20f0daa44f244ba to your computer and use it in GitHub Desktop.
Save ironpythonbot/e5a4a20f0daa44f244ba to your computer and use it in GitHub Desktop.
CodePlex Issue #34386 Plain Text Attachments
import unittest, sys, traceback
class TestTraceback(unittest.TestCase):
def test_truncate_traceback_with_typeerror(self):
def task3():
return (1, 2) + [3, 4] # TypeError
def task2():
task3()
def task1():
try:
task2()
except:
raise
try:
task1()
self.fail()
except:
exc_type, exc_value, exc_traceback = sys.exc_info()
methods = [function_name for filename, line_number, function_name, text in traceback.extract_tb(exc_traceback)]
self.assertEqual(methods, ['test_truncate_traceback_with_typeerror', 'task1', 'task2', 'task3'])
def test_keep_traceback_with_exception(self):
def task3():
raise Exception('ahhh')
def task2():
task3()
def task1():
try:
task2()
except:
raise
try:
task1()
self.fail()
except:
exc_type, exc_value, exc_traceback = sys.exc_info()
methods = [function_name for filename, line_number, function_name, text in traceback.extract_tb(exc_traceback)]
self.assertEqual(methods, ['test_keep_traceback_with_exception', 'task1', 'task2', 'task3'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment