[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#855429: unblock: python-irc/8.5.3+dfsg-4



Package: release.debian.org
Severity: normal
User: release.debian.org@packages.debian.org
Usertags: unblock

Please unblock package python-irc.

Version “8.5.3+dfsg-4” resolves bug#854539 by patching some unit tests.

unblock python-irc/8.5.3+dfsg-4

-- 
 \       “Nothing exists except atoms and empty space; everything else |
  `\                                          is opinion.” —Democritus |
_o__)                                                                  |
Ben Finney <bignose@debian.org>
diff -Nru python-irc-8.5.3+dfsg/debian/changelog python-irc-8.5.3+dfsg/debian/changelog
--- python-irc-8.5.3+dfsg/debian/changelog	2016-12-29 08:41:09.000000000 +1100
+++ python-irc-8.5.3+dfsg/debian/changelog	2017-02-18 06:48:31.000000000 +1100
@@ -1,3 +1,11 @@
+python-irc (8.5.3+dfsg-4) unstable; urgency=medium
+
+  * The “Faisal Arefin Dipan” release.
+  * Patch the unit tests to use a fake system clock.
+    Closes: bug#854539.
+
+ -- Ben Finney <bignose@debian.org>  Sat, 18 Feb 2017 06:48:31 +1100
+
 python-irc (8.5.3+dfsg-3) unstable; urgency=medium
 
   * The “Mukto-Mona” release.
diff -Nru python-irc-8.5.3+dfsg/debian/patches/02-fake-clock-for-tests.patch python-irc-8.5.3+dfsg/debian/patches/02-fake-clock-for-tests.patch
--- python-irc-8.5.3+dfsg/debian/patches/02-fake-clock-for-tests.patch	1970-01-01 10:00:00.000000000 +1000
+++ python-irc-8.5.3+dfsg/debian/patches/02-fake-clock-for-tests.patch	2017-02-18 06:48:31.000000000 +1100
@@ -0,0 +1,57 @@
+Description: Use a fake system clock for unit tests.
+ .
+ This removes a non-deterministic dependency on the real system clock.
+Bug-Debian: http://bugs.debian.org/854539
+Author: Ben Finney <bignose@debian.org>
+Last-Update: 2017-02-18
+
+
+diff --git i/irc/tests/test_client.py w/irc/tests/test_client.py
+index 1e2a8ddb..fd6fb9bf 100644
+--- i/irc/tests/test_client.py
++++ w/irc/tests/test_client.py
+@@ -44,6 +44,44 @@ class TestHandlers(object):
+ 		assert not handler1 < handler2
+ 		assert not handler2 < handler1
+ 
++
++class FakeClock(object):
++	""" A fake clock that is under control of test cases. """
++
++	_default_initial_seconds = 1450000000.0
++	_default_tick_duration = 0.0005
++
++	def __init__(
++			self,
++			seconds=_default_initial_seconds,
++			tick_duration=_default_tick_duration,
++	):
++		self._tick_duration = tick_duration
++		self.reset(seconds)
++
++	def reset(self, seconds):
++		""" Reset the clock time to `seconds`. """
++		self._seconds = seconds
++
++	def advance(self, seconds):
++		""" Advance the clock by `seconds`. """
++		self._seconds += max(0, seconds)
++
++	def tick(self):
++		""" Advance the clock by its tick duration. """
++		self.advance(self._tick_duration)
++
++	def time(self):
++		""" Get the current time, as seconds since epoch. """
++		self.tick()
++		return self._seconds
++
++
++fake_clock = FakeClock()
++
++
++@mock.patch.object(time, 'time', new=fake_clock.time)
++@mock.patch.object(time, 'sleep', new=fake_clock.advance)
+ class TestThrottler(object):
+ 	def test_function_throttled(self):
+ 		"""
diff -Nru python-irc-8.5.3+dfsg/debian/patches/series python-irc-8.5.3+dfsg/debian/patches/series
--- python-irc-8.5.3+dfsg/debian/patches/series	2016-12-29 08:41:09.000000000 +1100
+++ python-irc-8.5.3+dfsg/debian/patches/series	2017-02-18 06:48:31.000000000 +1100
@@ -1 +1,2 @@
 01-setup.patch
+02-fake-clock-for-tests.patch

Attachment: signature.asc
Description: PGP signature


Reply to: