Пример #1
0
 def formatException(self, ei):
     if self.extended_traceback:
         s = formatExtendedTraceback(ei[1])
     else:
         s = ''.join(
             traceback.format_exception(ei[0], ei[1], ei[2], sys.maxsize))
         if s.endswith('\n'):
             s = s[:-1]
     return s
Пример #2
0
def test_traceback():
    a = 1  # pylint: disable=unused-variable
    f = sys._getframe()
    fmt = formatExtendedFrame(f)
    assert any('a                    = 1' in line for line in fmt)

    try:
        1 / 0
    except ZeroDivisionError:
        ei = sys.exc_info()
        tb = formatExtendedTraceback(*ei)
        assert 'ZeroDivisionError' in tb
        assert ', in test_traceback' in tb

    st = formatExtendedStack()
    assert ', in test_traceback' in st
Пример #3
0
def test_traceback():
    a = 1  # pylint: disable=unused-variable
    f = sys._getframe()
    fmt = formatExtendedFrame(f)
    assert any('a                    = 1' in line for line in fmt)

    try:
        try:
            1 / 0
        except ZeroDivisionError as err:
            raise RuntimeError from err
    except Exception:
        ei = sys.exc_info()
        tb = formatExtendedTraceback(ei[1])
        assert 'ZeroDivisionError' in tb
        assert 'RuntimeError' in tb
        assert TB_CAUSE_MSG in tb
        assert ', in test_traceback' in tb

    st = formatExtendedStack()
    assert ', in test_traceback' in st