@@ -44,6 +44,7 @@ def send(self, timeout=None):
44
44
45
45
def tick (self , dt = 1 ):
46
46
self ._current_tick += dt
47
+ return self ._current_tick
47
48
48
49
49
50
class TestCurtsiesPasteDetection (TestCase ):
@@ -63,9 +64,11 @@ def test_paste_threshold(self):
63
64
self .assertEqual (next (cb ), None )
64
65
65
66
def test_set_timeout (self ):
66
- eg = EventGenerator ('a' , zip ('bcd' , [1 ,2 ,3 ]))
67
+ eg = EventGenerator ('a' , zip ('bcdefg' , [1 , 2 , 3 , 3 , 3 , 4 ]))
68
+ eg .schedule_event (curtsies .events .SigIntEvent (), 5 )
69
+ eg .schedule_event ('h' , 6 )
67
70
inputs = combined_events (eg )
68
- cb = combined_events (inputs , paste_threshold = 5 )
71
+ cb = combined_events (inputs , paste_threshold = 3 )
69
72
self .assertEqual (next (cb ), 'a' )
70
73
self .assertEqual (cb .send (0 ), None )
71
74
self .assertEqual (next (cb ), 'b' )
@@ -74,9 +77,15 @@ def test_set_timeout(self):
74
77
self .assertEqual (cb .send (0 ), 'c' )
75
78
self .assertEqual (cb .send (0 ), None )
76
79
eg .tick ()
77
- self .assertEqual (cb .send (0 ), 'd' )
80
+ self .assertIsInstance (cb .send (0 ), curtsies . events . PasteEvent )
78
81
self .assertEqual (cb .send (0 ), None )
79
-
82
+ self .assertEqual (cb .send (None ), 'g' )
83
+ self .assertEqual (cb .send (0 ), None )
84
+ eg .tick (1 )
85
+ self .assertIsInstance (cb .send (0 ), curtsies .events .SigIntEvent )
86
+ self .assertEqual (cb .send (0 ), None )
87
+ self .assertEqual (cb .send (None ), 'h' )
88
+ self .assertEqual (cb .send (None ), None )
80
89
81
90
82
91
if __name__ == '__main__' :
0 commit comments