def test_toplevel_frame_has_no_parent():
    frame = inspect.currentframe()

    while frame.f_back is not None:
        frame = frame.f_back

    frame = CallFrame.from_frame(frame)

    assert frame.parent is None
def test_attrs():
    frame1 = inspect.currentframe()
    frame2 = CallFrame.from_frame(frame1)

    assert frame2.parent == frame1.f_back
    assert frame2.locals is frame1.f_locals
    assert frame2.globals is frame1.f_globals
    assert frame2.builtins is frame1.f_builtins
    assert frame2.code_object is frame1.f_code
def test_equality(orig_frame):
    frame = CallFrame.from_frame(orig_frame)

    assert frame == orig_frame