コード例 #1
0
def test_do_not_trace_non_deferred_returns():
    """
    If a function returns a non-Deferred value, nothing happens. More
    specifically, no function trace information is stored.
    """
    t = Tracer()
    t._trace(FakeFrame(), 'return', None)
    assert not t._function_data
コード例 #2
0
def test_do_not_trace_non_deferred_returns():
    """
    If a function returns a non-Deferred value, nothing happens. More
    specifically, no function trace information is stored.
    """
    t = Tracer()
    t._trace(FakeFrame(), 'return', None)
    assert not t._function_data
コード例 #3
0
def test_trace_deferred_return_initial_setup():
    """
    If a function returns a Deferred, nothing happens until the Deferred
    fires. More specifically, no function trace information is stored.
    """
    t = Tracer()
    d = defer.Deferred()
    t._trace(_frame_spam, 'return', d)
    assert not t._function_data
コード例 #4
0
def test_do_not_trace_defer_module():
    """
    If a function in twisted.internet.defer returns a Deferred, nothing
    happens. More specifically, no function trace information is stored.
    """
    t = Tracer()
    t._trace(FakeFrame(globals={'__name__': 'twisted.internet.defer'}),
             'return', defer.Deferred())
    assert not t._function_data
コード例 #5
0
def test_do_not_trace_generators():
    """
    If a generator function returns a Deferred, nothing happens. More
    specifically, no function trace information is stored.
    """
    t = Tracer()
    t._trace(FakeFrame(FakeCode(flags=inspect.CO_GENERATOR)), 'return',
             defer.Deferred())
    assert not t._function_data
コード例 #6
0
def test_trace_deferred_return_initial_setup():
    """
    If a function returns a Deferred, nothing happens until the Deferred
    fires. More specifically, no function trace information is stored.
    """
    t = Tracer()
    d = defer.Deferred()
    t._trace(_frame_spam, 'return', d)
    assert not t._function_data
コード例 #7
0
def test_do_not_trace_defer_module():
    """
    If a function in twisted.internet.defer returns a Deferred, nothing
    happens. More specifically, no function trace information is stored.
    """
    t = Tracer()
    t._trace(
        FakeFrame(globals={'__name__': 'twisted.internet.defer'}),
        'return', defer.Deferred())
    assert not t._function_data
コード例 #8
0
def test_do_not_trace_generators():
    """
    If a generator function returns a Deferred, nothing happens. More
    specifically, no function trace information is stored.
    """
    t = Tracer()
    t._trace(
        FakeFrame(FakeCode(flags=inspect.CO_GENERATOR)),
        'return', defer.Deferred())
    assert not t._function_data
コード例 #9
0
def test_tracer_wrapped_hook(fakesys):
    """
    If a profile hook was set prior to calling Tracer's install method, it will
    continue to be called by Tracer.
    """
    calls = []

    def tracer(frame, event, arg):
        calls.append((frame, event, arg))
    fakesys.tracer = tracer
    t = Tracer()
    t.install()
    sentinel = object()
    t._trace(sentinel, 'call', sentinel)
    assert calls == [(sentinel, 'call', sentinel)]
コード例 #10
0
def test_tracer_wrapped_hook(fakesys):
    """
    If a profile hook was set prior to calling Tracer's install method, it will
    continue to be called by Tracer.
    """
    calls = []

    def tracer(frame, event, arg):
        calls.append((frame, event, arg))

    fakesys.tracer = tracer
    t = Tracer()
    t.install()
    sentinel = object()
    t._trace(sentinel, 'call', sentinel)
    assert calls == [(sentinel, 'call', sentinel)]