Skip to content

Commit 7c306d4

Browse files
committed
fix handling of hint in bulk
1 parent 735badf commit 7c306d4

File tree

2 files changed

+22
-12
lines changed

2 files changed

+22
-12
lines changed

test/unified_format.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -286,11 +286,11 @@ def get_lsid_for_session(self, session_name):
286286
if not PY3:
287287
binary_types = (Binary,)
288288
long_types = (Int64, long)
289-
unicode_types = (unicode,)
289+
unicode_type = unicode
290290
else:
291291
binary_types = (Binary, bytes)
292292
long_types = (Int64,)
293-
unicode_types = (str,)
293+
unicode_type = str
294294

295295

296296
BSON_TYPE_ALIAS_MAP = {
@@ -308,9 +308,9 @@ def get_lsid_for_session(self, session_name):
308308
'null': (type(None),),
309309
'regex': (Regex, RE_TYPE),
310310
'dbPointer': (DBRef,),
311-
'javascript': (*unicode_types, Code),
312-
'symbol': unicode_types,
313-
'javascriptWithScope': (*unicode_types, Code),
311+
'javascript': (unicode_type, Code),
312+
'symbol': (unicode_type,),
313+
'javascriptWithScope': (unicode_type, Code),
314314
'int': (int,),
315315
'long': (Int64,),
316316
'decimal': (Decimal128,),
@@ -928,7 +928,7 @@ def test_case(self):
928928
test_name = 'test_%s' % (description.strip('. ').
929929
replace(' ', '_').replace('.', '_'),)
930930
test_method = create_test(copy.deepcopy(test_spec))
931-
test_method.__name__ = test_name
931+
test_method.__name__ = str(test_name)
932932

933933
for fail_pattern in cls.EXPECTED_FAILURES:
934934
if re.search(fail_pattern, description):

test/utils.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -988,13 +988,23 @@ def parse_spec_options(opts):
988988
if 'requests' in opts:
989989
reqs = opts.pop('requests')
990990
for req in reqs:
991-
args = req.pop('arguments', {})
992-
if 'hint' in args:
993-
hint = args.pop('hint')
994-
if not isinstance(hint, string_type):
995-
hint = list(iteritems(hint))
991+
if 'name' in req:
992+
# CRUD v2 format
993+
args = req.pop('arguments', {})
994+
if 'hint' in args:
995+
hint = args.pop('hint')
996+
if not isinstance(hint, string_type):
997+
hint = list(iteritems(hint))
996998
args['hint'] = hint
997-
req['arguments'] = args
999+
req['arguments'] = args
1000+
else:
1001+
# Unified test format
1002+
bulk_model, spec = next(iteritems(req))
1003+
if 'hint' in spec:
1004+
hint = spec.pop('hint')
1005+
if not isinstance(hint, string_type):
1006+
hint = list(iteritems(hint))
1007+
spec['hint'] = hint
9981008
opts['requests'] = reqs
9991009

10001010
return dict(opts)

0 commit comments

Comments
 (0)