Пример #1
0
def test_capture():
    stack = backtrace.capture()

    assert isinstance(stack, list)
    assert len(stack) >= 1
    for frame in stack:
        assert isinstance(frame, dict)
        assert set(frame.keys()) == {"file", "line", "function"}
        assert isinstance(frame["file"], str)
        assert isinstance(frame["line"], int)
        assert isinstance(frame["function"], str)

    assert stack[0]["file"] == format_py_filename(__file__)
Пример #2
0
def test_traceback_contains_file_line_function():
    traceback = backtrace.capture()
    for frame in traceback:
        assert set(frame) == {"file", "line", "function"}
Пример #3
0
def test_traceback_contains_inner_frame_first():
    traceback = backtrace.capture()
    # Consider removing the frame corresponding to the capture() call?
    # On Python 2, __file__ points to the compiled bytecode, not the source.
    assert traceback[0]["file"] == backtrace.__file__.replace(".pyc", ".py")
    assert traceback[1]["file"] == __file__.replace(".pyc", ".py")
Пример #4
0
def test_traceback_returns_correct_types():
    traceback = backtrace.capture()
    for frame in traceback:
        assert isinstance(frame["file"], str)
        assert isinstance(frame["line"], int)
        assert isinstance(frame["function"], str)
 def capture_backtrace(self):
     self.tag("stack", backtrace.capture())
Пример #6
0
 def capture_recursive_bottom(limit):
     if limit <= 1:
         return backtrace.capture()
     else:
         return capture_recursive_bottom(limit - 1)