示例#1
0
def run_loop():
    tracer.start()

    for i in range(5):
        a = i
        for j in range(5):
            b = i + j
            for k in range(2):
                c = i + j + k

    tracer.stop()
示例#2
0
"""Certain instructions can only be tested outside of a function."""

from cyberbrain import tracer, InitialValue, Deletion, Mutation, Symbol
from utils import assert_GetFrame

x = 1

tracer.start()
del x  # DELETE_NAME
y: int
tracer.stop()


def test_module(rpc_stub):
    assert tracer.events == [
        InitialValue(target=Symbol("x"), value=1, lineno=10),
        Deletion(target=Symbol("x"), lineno=10),
        InitialValue(target=Symbol("__annotations__"), value={}, lineno=11),
        Mutation(
            target=Symbol("__annotations__"),
            value={"y": int},
            sources={Symbol("__annotations__")
                     },  # `int` is a built-in so is excluded from sources.
            lineno=11,
        ),
    ]

    assert_GetFrame(rpc_stub, "test_outside_func")
示例#3
0
def hello():
    tracer.start()
    x = "hello"
    y = x + " world"
    x, y = y, x
    tracer.stop()