@@ -30,9 +30,13 @@ def setUpClass(cls):
30
30
cls .listener = OvertCommandListener ()
31
31
cls .client = single_client (event_listeners = [cls .listener ])
32
32
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' )
33
38
34
39
def tearDown (self ):
35
- self .db .coll .drop ()
36
40
self .listener .results .clear ()
37
41
38
42
def test_read_concern (self ):
@@ -104,12 +108,8 @@ def test_command_cursor(self):
104
108
105
109
def test_aggregate_out (self ):
106
110
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' }]))
113
113
114
114
# Aggregate with $out supports readConcern MongoDB 4.2 onwards.
115
115
if client_context .version >= (4 , 1 ):
@@ -121,40 +121,28 @@ def test_aggregate_out(self):
121
121
122
122
def test_map_reduce_out (self ):
123
123
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' )
131
127
self .assertNotIn ('readConcern' ,
132
128
self .listener .results ['started' ][0 ].command )
133
129
134
130
if client_context .version .at_least (3 , 1 , 9 , - 1 ):
135
131
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 })
144
136
self .assertEqual (
145
137
{'level' : 'local' },
146
138
self .listener .results ['started' ][0 ].command ['readConcern' ])
147
139
148
140
@client_context .require_version_min (3 , 1 , 9 , - 1 )
149
141
def test_inline_map_reduce (self ):
150
142
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; }' ))
158
146
self .assertEqual (
159
147
{'level' : 'local' },
160
148
self .listener .results ['started' ][0 ].command ['readConcern' ])
0 commit comments