| 1 | # file scalene/scalene_statistics.py:242-246 |
| 2 | # lines [244, 245, 246] |
| 3 | # branches ['244->245', '244->246'] |
| 4 | |
| 5 | import time |
| 6 | from scalene.scalene_statistics import ScaleneStatistics |
| 7 | |
| 8 | |
| 9 | def test_stop_clock(): |
| 10 | stats = ScaleneStatistics() |
| 11 | # Set the start_time to a non-zero value to ensure the if condition is met |
| 12 | stats.start_time = time.time() |
| 13 | # Sleep for a short duration to simulate elapsed time |
| 14 | time.sleep(0.1) |
| 15 | stats.stop_clock() |
| 16 | # Check if elapsed_time has been updated |
| 17 | assert stats.elapsed_time > 0 |
| 18 | # Check if start_time has been reset to 0 |
| 19 | assert stats.start_time == 0 |