From b2f6c3c83fe2c460dd17978d9d1b378e17baf448 Mon Sep 17 00:00:00 2001 From: Valentin Lorentz Date: Mon, 11 Nov 2019 18:06:07 +0100 Subject: [PATCH] test: Don't overwrite the main Schedule in the driver list. Closes GH-1385. --- test/test_schedule.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/test/test_schedule.py b/test/test_schedule.py index 647bb6713..8749269b1 100644 --- a/test/test_schedule.py +++ b/test/test_schedule.py @@ -33,9 +33,18 @@ import time import supybot.schedule as schedule +# Use a different driver name than the main Schedule, because Schedule +# is a driver so it self-registers in the dict of drivers with its name. +# So by keeping the name we overwrite the main Schedule in the dict of +# drivers (which is supposed to be in sync with the one accessible +# as supybot.schedule.schedule). +class FakeSchedule(schedule.Schedule): + def name(self): + return 'FakeSchedule' + class TestSchedule(SupyTestCase): def testSchedule(self): - sched = schedule.Schedule() + sched = FakeSchedule() i = [0] def add10(): i[0] = i[0] + 10 @@ -60,7 +69,7 @@ class TestSchedule(SupyTestCase): self.assertEqual(i[0], 11) def testReschedule(self): - sched = schedule.Schedule() + sched = FakeSchedule() i = [0] def inc(): i[0] += 1 @@ -74,7 +83,7 @@ class TestSchedule(SupyTestCase): self.assertEqual(i[0], 1) def testPeriodic(self): - sched = schedule.Schedule() + sched = FakeSchedule() i = [0] def inc(): i[0] += 1 @@ -97,7 +106,7 @@ class TestSchedule(SupyTestCase): self.assertEqual(i[0], 3) def testCountedPeriodic(self): - sched = schedule.Schedule() + sched = FakeSchedule() i = [0] def inc(): i[0] += 1