mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-26 20:59:27 +01:00
test: Don't overwrite the main Schedule in the driver list.
Closes GH-1385.
This commit is contained in:
parent
5718eafc07
commit
b2f6c3c83f
@ -33,9 +33,18 @@ import time
|
|||||||
|
|
||||||
import supybot.schedule as schedule
|
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):
|
class TestSchedule(SupyTestCase):
|
||||||
def testSchedule(self):
|
def testSchedule(self):
|
||||||
sched = schedule.Schedule()
|
sched = FakeSchedule()
|
||||||
i = [0]
|
i = [0]
|
||||||
def add10():
|
def add10():
|
||||||
i[0] = i[0] + 10
|
i[0] = i[0] + 10
|
||||||
@ -60,7 +69,7 @@ class TestSchedule(SupyTestCase):
|
|||||||
self.assertEqual(i[0], 11)
|
self.assertEqual(i[0], 11)
|
||||||
|
|
||||||
def testReschedule(self):
|
def testReschedule(self):
|
||||||
sched = schedule.Schedule()
|
sched = FakeSchedule()
|
||||||
i = [0]
|
i = [0]
|
||||||
def inc():
|
def inc():
|
||||||
i[0] += 1
|
i[0] += 1
|
||||||
@ -74,7 +83,7 @@ class TestSchedule(SupyTestCase):
|
|||||||
self.assertEqual(i[0], 1)
|
self.assertEqual(i[0], 1)
|
||||||
|
|
||||||
def testPeriodic(self):
|
def testPeriodic(self):
|
||||||
sched = schedule.Schedule()
|
sched = FakeSchedule()
|
||||||
i = [0]
|
i = [0]
|
||||||
def inc():
|
def inc():
|
||||||
i[0] += 1
|
i[0] += 1
|
||||||
@ -97,7 +106,7 @@ class TestSchedule(SupyTestCase):
|
|||||||
self.assertEqual(i[0], 3)
|
self.assertEqual(i[0], 3)
|
||||||
|
|
||||||
def testCountedPeriodic(self):
|
def testCountedPeriodic(self):
|
||||||
sched = schedule.Schedule()
|
sched = FakeSchedule()
|
||||||
i = [0]
|
i = [0]
|
||||||
def inc():
|
def inc():
|
||||||
i[0] += 1
|
i[0] += 1
|
||||||
|
Loading…
Reference in New Issue
Block a user