예제 #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
예제 #2
0
def test_context_manager():
    with time.StopWatch() as watch:
        pass
    assert watch.elapsed() > 0
예제 #3
0
def test_elapsed():
    watch = time.StopWatch()
    watch.start()
    watch.stop()
    assert watch.elapsed() > 0
예제 #4
0
def test_no_elapsed():
    watch = time.StopWatch()
    with pytest.raises(RuntimeError):
        watch.elapsed()
예제 #5
0
def test_start_stop():
    watch = time.StopWatch()
    watch.start()
    watch.stop()
예제 #6
0
def test_no_states():
    watch = time.StopWatch()
    with pytest.raises(RuntimeError):
        watch.stop()