Skip to content

Commit

Permalink
Merge pull request #139 from Leterax/master
Browse files Browse the repository at this point in the history
fix scheduling test
  • Loading branch information
einarf authored Jun 25, 2021
2 parents a83b49a + 699e972 commit 9d9c8ee
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions tests/test_scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,17 @@ def test_clock_timer(self):

self.test_value = 0
event = scheduler.run_every(self.increase_value, 0.1)
for _ in range(30):
start = time.time()
delta = time.time()
while (delta - start) <= 0.5:
# simulate a render loop
scheduler.execute()
print(self.test_value)
time.sleep(0.01)
self.assertEqual(self.test_value, 3)

scheduler.execute()
delta = time.time()
self.assertEqual(self.test_value, 5)
# make sure it stays 5 once we cancel the event
scheduler.cancel(event)
time.sleep(0.2)
time.sleep(0.11)
scheduler.execute()
self.assertEqual(self.test_value, 3)
self.assertEqual(self.test_value, 5)

0 comments on commit 9d9c8ee

Please sign in to comment.