Skip to content
This repository has been archived by the owner on Feb 5, 2023. It is now read-only.

Commit

Permalink
Update test_with-statement.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Muhan Li committed Feb 8, 2021
1 parent c4b07a2 commit 5599c13
Showing 1 changed file with 31 additions and 3 deletions.
34 changes: 31 additions & 3 deletions timework/test_with-statement.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import time


def test_no_split():
"""
output example:
Expand All @@ -21,10 +22,9 @@ def test_no_split():
s.resume()
assert s._running is True
time.sleep(.5)
split, total = s.get_hms()
split, total = s.get_sec()
assert split == total
sec, _ = s.get_sec()
assert sec == tw.hms_to_sec(split)
assert split == tw.hms_to_sec(tw.sec_to_hms(total))
time.sleep(.6)
assert s._running is True
s.stop()
Expand Down Expand Up @@ -58,3 +58,31 @@ def test_split():
assert s._start_at - s._initial > .6
time.sleep(.7)
assert s._running is True


def test_restart():
"""
output example:
[TIMEWORK] Start: Mon Feb 8 17:14:57 2021
[TIMEWORK] Split: 00:00:00.312 | 00:00:00.312
[TIMEWORK] Stop: 00:00:01.119
[TIMEWORK] Stop: 00:00:00.709
[TIMEWORK] Finish: Mon Feb 8 17:15:00 2021
"""
for _ in range(3):
with tw.Stopwatch() as s:
assert s._running is True
time.sleep(.3)
s.split()
time.sleep(.4)
s.restart()
assert s._running is True
time.sleep(.5)
split, total = s.get_sec()
assert total < .6
time.sleep(.6)
s.stop()
assert s._running is False
s.restart()
time.sleep(.7)
assert s._running is True

0 comments on commit 5599c13

Please sign in to comment.