@@ -30,9 +30,13 @@ def setUpClass(cls):
3030 cls .listener = OvertCommandListener ()
3131 cls .client = single_client (event_listeners = [cls .listener ])
3232 cls .db = cls .client .pymongo_test
33+ client_context .client .pymongo_test .create_collection ('coll' )
34+
35+ @classmethod
36+ def tearDownClass (cls ):
37+ client_context .client .pymongo_test .drop_collection ('coll' )
3338
3439 def tearDown (self ):
35- self .db .coll .drop ()
3640 self .listener .results .clear ()
3741
3842 def test_read_concern (self ):
@@ -104,12 +108,8 @@ def test_command_cursor(self):
104108
105109 def test_aggregate_out (self ):
106110 coll = self .db .get_collection ('coll' , read_concern = ReadConcern ('local' ))
107- try :
108- tuple (coll .aggregate ([{'$match' : {'field' : 'value' }},
109- {'$out' : 'output_collection' }]))
110- except OperationFailure :
111- # "ns doesn't exist"
112- pass
111+ tuple (coll .aggregate ([{'$match' : {'field' : 'value' }},
112+ {'$out' : 'output_collection' }]))
113113
114114 # Aggregate with $out supports readConcern MongoDB 4.2 onwards.
115115 if client_context .version >= (4 , 1 ):
@@ -121,40 +121,28 @@ def test_aggregate_out(self):
121121
122122 def test_map_reduce_out (self ):
123123 coll = self .db .get_collection ('coll' , read_concern = ReadConcern ('local' ))
124- try :
125- tuple (coll .map_reduce ('function() { emit(this._id, this.value); }' ,
126- 'function(key, values) { return 42; }' ,
127- out = 'output_collection' ))
128- except OperationFailure :
129- # "ns doesn't exist"
130- pass
124+ coll .map_reduce ('function() { emit(this._id, this.value); }' ,
125+ 'function(key, values) { return 42; }' ,
126+ out = 'output_collection' )
131127 self .assertNotIn ('readConcern' ,
132128 self .listener .results ['started' ][0 ].command )
133129
134130 if client_context .version .at_least (3 , 1 , 9 , - 1 ):
135131 self .listener .results .clear ()
136- try :
137- tuple (coll .map_reduce (
138- 'function() { emit(this._id, this.value); }' ,
139- 'function(key, values) { return 42; }' ,
140- out = {'inline' : 1 }))
141- except OperationFailure :
142- # "ns doesn't exist"
143- pass
132+ coll .map_reduce (
133+ 'function() { emit(this._id, this.value); }' ,
134+ 'function(key, values) { return 42; }' ,
135+ out = {'inline' : 1 })
144136 self .assertEqual (
145137 {'level' : 'local' },
146138 self .listener .results ['started' ][0 ].command ['readConcern' ])
147139
148140 @client_context .require_version_min (3 , 1 , 9 , - 1 )
149141 def test_inline_map_reduce (self ):
150142 coll = self .db .get_collection ('coll' , read_concern = ReadConcern ('local' ))
151- try :
152- tuple (coll .inline_map_reduce (
153- 'function() { emit(this._id, this.value); }' ,
154- 'function(key, values) { return 42; }' ))
155- except OperationFailure :
156- # "ns doesn't exist"
157- pass
143+ tuple (coll .inline_map_reduce (
144+ 'function() { emit(this._id, this.value); }' ,
145+ 'function(key, values) { return 42; }' ))
158146 self .assertEqual (
159147 {'level' : 'local' },
160148 self .listener .results ['started' ][0 ].command ['readConcern' ])
0 commit comments