Commits

Jason R. Coombs committed d6bff5e

Added test for periodic_command_fixed_delay and fixed an issue identified by it.

  • Participants
  • Parent commits bb7ac56
  • Tags 2.0

Comments (0)

Files changed (2)

         if not isinstance(delay, datetime.timedelta):
             delay = datetime.timedelta(seconds=delay)
         at = cls.now() + delay
-        cmd = datetime.datetime.__new__(DelayedCommand, at.year,
+        cmd = datetime.datetime.__new__(cls, at.year,
             at.month, at.day, at.hour, at.minute, at.second,
             at.microsecond, at.tzinfo)
         cmd.delay = delay

irc/tests/test_irclib.py

+import datetime
 import random
 
 import irc.client
 		for delay in delays
 	])
 	assert [c.delay.seconds for c in cmds] == sorted(delays)
+
+def test_periodic_command_fixed_delay():
+	"""
+	Test that we can construct a periodic command with a fixed initial
+	delay.
+	"""
+	fd = irc.client.PeriodicCommandFixedDelay.at_time(
+		at = datetime.datetime.now(),
+		delay = datetime.timedelta(seconds=2),
+		function = lambda: None,
+		arguments = [],
+		)
+	assert fd.due() == True
+	assert fd.next().due() == False