File tree Expand file tree Collapse file tree 3 files changed +21
-7
lines changed Expand file tree Collapse file tree 3 files changed +21
-7
lines changed Original file line number Diff line number Diff line change @@ -49,6 +49,7 @@ class TestAllScenarios(unittest.TestCase):
4949 @client_context .require_connection
5050 def setUpClass (cls ):
5151 cls .listener = EventListener ()
52+ cls .listener .add_command_filter ('killCursors' )
5253 cls .saved_listeners = monitoring ._LISTENERS
5354 monitoring ._LISTENERS = monitoring ._Listeners ([])
5455 cls .client = single_client (event_listeners = [cls .listener ])
@@ -101,10 +102,11 @@ def run_scenario(self):
101102 except OperationFailure :
102103 pass
103104 elif name == 'find' :
104- # XXX: Skip killCursors test when using the find command.
105- if (client_context .version .at_least (3 , 1 , 1 ) and
106- 'limit' in args ):
107- continue
105+ if 'limit' in args :
106+ # XXX: Skip killCursors test when using the find command.
107+ if client_context .version .at_least (3 , 1 , 1 ):
108+ continue
109+ self .listener .remove_command_filter ('killCursors' )
108110 if 'sort' in args :
109111 args ['sort' ] = list (args ['sort' ].items ())
110112 try :
@@ -118,6 +120,7 @@ def run_scenario(self):
118120 wait_until (
119121 lambda : started [- 1 ].command_name == 'killCursors' ,
120122 "publish a start event for killCursors." )
123+ self .listener .add_command_filter ('killCursors' )
121124 else :
122125 try :
123126 getattr (coll , name )(** args )
Original file line number Diff line number Diff line change @@ -226,6 +226,7 @@ def test_max_await_time_ms(self):
226226 self .assertEqual (90 , cursor ._Cursor__max_await_time_ms )
227227
228228 listener = EventListener ()
229+ listener .add_command_filter ('killCursors' )
229230 saved_listeners = monitoring ._LISTENERS
230231 monitoring ._LISTENERS = monitoring ._Listeners ([])
231232 coll = single_client (
Original file line number Diff line number Diff line change @@ -43,15 +43,25 @@ class EventListener(monitoring.CommandListener):
4343
4444 def __init__ (self ):
4545 self .results = defaultdict (list )
46+ self .filters = set ()
47+
48+ def add_command_filter (self , command_name ):
49+ self .filters .add (command_name )
50+
51+ def remove_command_filter (self , command_name ):
52+ self .filters .remove (command_name )
4653
4754 def started (self , event ):
48- self .results ['started' ].append (event )
55+ if event .command_name not in self .filters :
56+ self .results ['started' ].append (event )
4957
5058 def succeeded (self , event ):
51- self .results ['succeeded' ].append (event )
59+ if event .command_name not in self .filters :
60+ self .results ['succeeded' ].append (event )
5261
5362 def failed (self , event ):
54- self .results ['failed' ].append (event )
63+ if event .command_name not in self .filters :
64+ self .results ['failed' ].append (event )
5565
5666
5767def _connection_string_noauth (h , p ):
You can’t perform that action at this time.
0 commit comments