Ejemplo n.º 1
0
def test_start_stop_elapsed():
    watch = time.StopWatch()
    watch.start()
    watch.stop()
    e = watch.elapsed()
    assert e > 0
    watch.start()
    assert watch.elapsed() != e
Ejemplo n.º 2
0
def test_context_manager():
    with time.StopWatch() as watch:
        pass
    assert watch.elapsed() > 0
Ejemplo n.º 3
0
def test_elapsed():
    watch = time.StopWatch()
    watch.start()
    watch.stop()
    assert watch.elapsed() > 0
Ejemplo n.º 4
0
def test_no_elapsed():
    watch = time.StopWatch()
    with pytest.raises(RuntimeError):
        watch.elapsed()
Ejemplo n.º 5
0
def test_start_stop():
    watch = time.StopWatch()
    watch.start()
    watch.stop()
Ejemplo n.º 6
0
def test_no_states():
    watch = time.StopWatch()
    with pytest.raises(RuntimeError):
        watch.stop()