Skip to content

Commit a98078b

Browse files
committed
add a test for #466
1 parent 1299f4a commit a98078b

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

tests/unit/test_connection.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
from cassandra.cluster import Cluster, Session
2626
from cassandra.connection import (Connection, HEADER_DIRECTION_TO_CLIENT, ProtocolError,
27-
locally_supported_compressions, ConnectionHeartbeat, _Frame)
27+
locally_supported_compressions, ConnectionHeartbeat, _Frame, Timer, TimerManager)
2828
from cassandra.marshal import uint8_pack, uint32_pack, int32_pack
2929
from cassandra.protocol import (write_stringmultimap, write_int, write_string,
3030
SupportedMessage, ProtocolHandler)
@@ -413,3 +413,25 @@ def send_msg(msg, req_id, msg_callback):
413413
self.assertIsInstance(exc, Exception)
414414
self.assertEqual(exc.args, Exception('Connection heartbeat failure').args)
415415
holder.return_connection.assert_has_calls([call(connection)] * get_holders.call_count)
416+
417+
418+
class TimerTest(unittest.TestCase):
419+
420+
def test_timer_collision(self):
421+
# simple test demonstrating #466
422+
def f1():
423+
pass
424+
425+
def f2():
426+
pass
427+
428+
# same timeout, comparison will defer to the Timer object itself
429+
t1 = Timer(0, f1)
430+
t2 = Timer(0, f2)
431+
t2.end = t1.end
432+
433+
tm = TimerManager()
434+
tm.add_timer(t1)
435+
tm.add_timer(t2)
436+
# Prior to $466: "TypeError: unorderable types: Timer() < Timer()"
437+
tm.service_timeouts()

0 commit comments

Comments
 (0)