Exemplo n.º 1
0
 def testPyroTracebackArgs(self):
     try:
         crash()
     except ZeroDivisionError:
         ex_type, ex_value, ex_tb = sys.exc_info()
         tb1 = errors.get_pyro_traceback()
         tb2 = errors.get_pyro_traceback(ex_type, ex_value, ex_tb)
         assert tb2 == tb1
         tb1 = errors.format_traceback()
         tb2 = errors.format_traceback(ex_type, ex_value, ex_tb)
         assert tb2 == tb1
         tb2 = errors.format_traceback(detailed=True)
         assert tb1 != tb2
Exemplo n.º 2
0
 def testFormatTracebackDetail(self):
     with pytest.raises(ZeroDivisionError) as x:
         crash()
     tb = "".join(
         errors.format_traceback(x.type, x.value, x.tb, detailed=True))
     assert "p3 = p1 // p2" in tb
     assert "ZeroDivisionError" in tb
     assert " a = 10" in tb
     assert " q = 'whiteblack'" in tb
     assert " pre2 = 999" in tb
     assert " x = 999" in tb
Exemplo n.º 3
0
 def testExcepthook(self):
     # simply test the excepthook by calling it the way Python would
     try:
         crash()
     except ZeroDivisionError:
         pyro_tb = errors.format_traceback()
     with pytest.raises(TypeError) as x:
         crash("stringvalue")
     ex_type, ex_value, ex_tb = x.type, x.value, x.tb
     ex_value._pyroTraceback = pyro_tb  # set the remote traceback info
     oldstderr = sys.stderr
     try:
         sys.stderr = io.StringIO()
         errors.excepthook(ex_type, ex_value, ex_tb)
         output = sys.stderr.getvalue()
         assert "Remote traceback" in output
         assert "crash(\"stringvalue\")" in output
         assert "TypeError:" in output
         assert "ZeroDivisionError" in output
     finally:
         sys.stderr = oldstderr
Exemplo n.º 4
0
 def testPyroTraceback(self):
     try:
         crash()
     except ZeroDivisionError:
         pyro_tb = errors.format_traceback(detailed=True)
         assert " Extended stacktrace follows (most recent call last)\n" in pyro_tb
     try:
         crash("stringvalue")
     except TypeError as x:
         x._pyroTraceback = pyro_tb  # set the remote traceback info
         pyrotb = "".join(errors.get_pyro_traceback())
         assert "Remote traceback" in pyrotb
         assert "crash(\"stringvalue\")" in pyrotb
         assert "TypeError:" in pyrotb
         assert "ZeroDivisionError" in pyrotb
         del x._pyroTraceback
         pyrotb = "".join(errors.get_pyro_traceback())
         assert "Remote traceback" not in pyrotb
         assert "ZeroDivisionError" not in pyrotb
         assert "crash(\"stringvalue\")" in pyrotb
         assert "TypeError:" in pyrotb