Skip to content

Commit beb1d1a

Browse files
committed
Reduce StopWatch_TEST.py sleep times (#800)
Match test timing used in Stopwatch_TEST.cc Assisted-by: Gemini Next Signed-off-by: Steve Peters <scpeters@intrinsic.ai> (cherry picked from commit 8292148)
1 parent 1f1ab64 commit beb1d1a

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

src/python_pybind11/test/StopWatch_TEST.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ def runTimer(self, _time):
3434
self.assertEqual(timedelta(0), _time.elapsed_stop_time())
3535

3636
# Wait for some time...
37-
time.sleep(1)
37+
time.sleep(0.05)
3838
# Now the elapsed time should be greater than or equal to the time slept.
39-
self.assertGreaterEqual(_time.elapsed_run_time() + handleSteadyClock, timedelta(seconds=1))
39+
self.assertGreaterEqual(_time.elapsed_run_time() + handleSteadyClock, timedelta(milliseconds=50))
4040

4141
# Stop the timer.
4242
self.assertTrue(_time.stop())
@@ -45,16 +45,16 @@ def runTimer(self, _time):
4545
# The stop time should be greater than the start time.
4646
self.assertGreater(_time.stop_time(), _time.start_time())
4747
# The elapsed time should still be greater than the time slept.
48-
self.assertGreaterEqual(_time.elapsed_run_time() + handleSteadyClock, timedelta(seconds=1))
48+
self.assertGreaterEqual(_time.elapsed_run_time() + handleSteadyClock, timedelta(milliseconds=50))
4949

5050
# Save the elapsed time.
5151
elapsedTime = _time.elapsed_run_time()
5252

5353
# The timer is now stopped, let's sleep some more.
54-
time.sleep(1)
54+
time.sleep(0.05)
5555
# The elapsed stop time should be greater than or equal to the time
5656
# slept.
57-
self.assertGreaterEqual(_time.elapsed_stop_time() + handleSteadyClock, timedelta(seconds=1))
57+
self.assertGreaterEqual(_time.elapsed_stop_time() + handleSteadyClock, timedelta(milliseconds=50))
5858
# The elapsed time should be the same.
5959
self.assertEqual(elapsedTime, _time.elapsed_run_time())
6060

@@ -65,14 +65,14 @@ def runTimer(self, _time):
6565
# The timer should be running.
6666
self.assertTrue(_time.running())
6767
# Sleep for some time.
68-
time.sleep(1)
68+
time.sleep(0.05)
6969
# The elapsed stop time should remain the same
7070
self.assertEqual(elapsedStopTime, _time.elapsed_stop_time())
7171
# The elapsed time should be greater than the previous elapsed time.
7272
self.assertGreater(_time.elapsed_run_time(), elapsedTime)
7373
# The elapsed time should be greater than or equal to the the previous
7474
# two sleep times.
75-
self.assertGreaterEqual(_time.elapsed_run_time() + handleSteadyClock, timedelta(seconds=2))
75+
self.assertGreaterEqual(_time.elapsed_run_time() + handleSteadyClock, timedelta(milliseconds=100))
7676

7777
def test_constructor(self):
7878
watch = Stopwatch()

0 commit comments

Comments
 (0)