From dd2395fe91f1775811b5951406966c5a20d61c6d Mon Sep 17 00:00:00 2001 From: josh-deb Date: Wed, 6 Nov 2024 16:43:07 -0800 Subject: [PATCH] test timer nits --- beams/tests/test_timer.py | 59 ++++++++++++++++++++------------------- 1 file changed, 30 insertions(+), 29 deletions(-) diff --git a/beams/tests/test_timer.py b/beams/tests/test_timer.py index 9542b04..fc1c2d9 100644 --- a/beams/tests/test_timer.py +++ b/beams/tests/test_timer.py @@ -5,32 +5,33 @@ from beams.sequencer.helpers.Timer import Timer -class TestTimer(): - def test_elapsed(self): - t = Timer(name="test_elapsed", - timer_period_seconds=0.1, - is_periodic=False) - t.start_timer() - assert t.is_elapsed() is False - time.sleep(0.5) - assert t.is_elapsed() is True - - def test_timer_error(self): - t = Timer(name="test_error_not_started", - timer_period_seconds=0.1, - is_periodic=False) - with pytest.raises(RuntimeError): - t.get_elapsed() - with pytest.raises(RuntimeError): - t.is_elapsed() - - def test_periodic(self): - t = Timer(name="test_error_not_started", - timer_period_seconds=0.1, - auto_start=True, - is_periodic=True) - time.sleep(0.2) - assert t.is_elapsed() is True - assert t.is_elapsed() is False - time.sleep(0.1) - assert t.is_elapsed() is True +def test_elapsed(): + t = Timer(name="test_elapsed", + timer_period_seconds=0.1, + is_periodic=False) + t.start_timer() + assert not t.is_elapsed() + time.sleep(0.5) + assert t.is_elapsed() + + +def test_timer_error(): + t = Timer(name="test_error_not_started", + timer_period_seconds=0.1, + is_periodic=False) + with pytest.raises(RuntimeError): + t.get_elapsed() + with pytest.raises(RuntimeError): + t.is_elapsed() + + +def test_periodic(): + t = Timer(name="test_error_not_started", + timer_period_seconds=0.1, + auto_start=True, + is_periodic=True) + time.sleep(0.2) + assert t.is_elapsed() + assert not t.is_elapsed() + time.sleep(0.1) + assert t.is_elapsed()