Jason R. Coombs avatar Jason R. Coombs committed d6bff5e

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

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
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.