Пример #1
0
def test_recording():
    # profiling is a module not code.
    # but inspect.getmodule() works like with code of a module.
    assert RecordingStatistics(profiling).module == 'profiling'
    # use discard_child.
    stats = RecordingStatistics()
    assert None not in stats
    stats.ensure_child(None)
    assert None in stats
    stats.discard_child(None)
    assert None not in stats
    stats.discard_child(None)
    assert None not in stats
Пример #2
0
def test_recording():
    # profiling is a module not code.
    # but inspect.getmodule() works like with code of a module.
    assert RecordingStatistics(profiling).module == 'profiling'
    # use discard_child.
    stats = RecordingStatistics()
    assert None not in stats
    stats.ensure_child(None)
    assert None in stats
    stats.discard_child(None)
    assert None not in stats
    stats.discard_child(None)
    assert None not in stats
Пример #3
0
def test_recording():
    # profiling is a module not code.
    # but inspect.getmodule() works like with code of a module.
    assert RecordingStatistics(profiling).module == 'profiling'
    # use discard_child.
    stats = RecordingStatistics()
    assert None not in stats
    stats.ensure_child(None)
    assert None in stats
    stats.discard_child(None)
    assert None not in stats
    stats.discard_child(None)
    assert None not in stats
    # cannot be pickled.
    with pytest.raises(TypeError):
        pickle.dumps(stats)