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):
49
49
@client_context .require_connection
50
50
def setUpClass (cls ):
51
51
cls .listener = EventListener ()
52
+ cls .listener .add_command_filter ('killCursors' )
52
53
cls .saved_listeners = monitoring ._LISTENERS
53
54
monitoring ._LISTENERS = monitoring ._Listeners ([])
54
55
cls .client = single_client (event_listeners = [cls .listener ])
@@ -101,10 +102,11 @@ def run_scenario(self):
101
102
except OperationFailure :
102
103
pass
103
104
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' )
108
110
if 'sort' in args :
109
111
args ['sort' ] = list (args ['sort' ].items ())
110
112
try :
@@ -118,6 +120,7 @@ def run_scenario(self):
118
120
wait_until (
119
121
lambda : started [- 1 ].command_name == 'killCursors' ,
120
122
"publish a start event for killCursors." )
123
+ self .listener .add_command_filter ('killCursors' )
121
124
else :
122
125
try :
123
126
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):
226
226
self .assertEqual (90 , cursor ._Cursor__max_await_time_ms )
227
227
228
228
listener = EventListener ()
229
+ listener .add_command_filter ('killCursors' )
229
230
saved_listeners = monitoring ._LISTENERS
230
231
monitoring ._LISTENERS = monitoring ._Listeners ([])
231
232
coll = single_client (
Original file line number Diff line number Diff line change @@ -43,15 +43,25 @@ class EventListener(monitoring.CommandListener):
43
43
44
44
def __init__ (self ):
45
45
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 )
46
53
47
54
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 )
49
57
50
58
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 )
52
61
53
62
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 )
55
65
56
66
57
67
def _connection_string_noauth (h , p ):
You can’t perform that action at this time.
0 commit comments