Skip to content

Commit 26c3949

Browse files
committed
PYTHON-2489 Fix "no server" test suite, fix unified test runCommand (#543)
(cherry picked from commit 06924cb)
1 parent 9fdbdd1 commit 26c3949

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

test/__init__.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -905,14 +905,15 @@ def teardown():
905905
if garbage:
906906
assert False, '\n'.join(garbage)
907907
c = client_context.client
908-
if c and not client_context.is_data_lake:
909-
c.drop_database("pymongo-pooling-tests")
910-
c.drop_database("pymongo_test")
911-
c.drop_database("pymongo_test1")
912-
c.drop_database("pymongo_test2")
913-
c.drop_database("pymongo_test_mike")
914-
c.drop_database("pymongo_test_bernie")
915-
c.close()
908+
if c:
909+
if not client_context.is_data_lake:
910+
c.drop_database("pymongo-pooling-tests")
911+
c.drop_database("pymongo_test")
912+
c.drop_database("pymongo_test1")
913+
c.drop_database("pymongo_test2")
914+
c.drop_database("pymongo_test_mike")
915+
c.drop_database("pymongo_test_bernie")
916+
c.close()
916917

917918
# Jython does not support gc.get_objects.
918919
if not sys.platform.startswith('java'):

test/unified_format.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -674,9 +674,13 @@ def _collectionOperation_createChangeStream(self, target, *args, **kwargs):
674674
return self.__entityOperation_createChangeStream(
675675
target, *args, **kwargs)
676676

677-
def _databaseOperation_runCommand(self, target, *args, **kwargs):
677+
def _databaseOperation_runCommand(self, target, **kwargs):
678678
self.__raise_if_unsupported('runCommand', target, Database)
679-
return target.command(*args, **kwargs)
679+
# Ensure the first key is the command name.
680+
ordered_command = SON([(kwargs.pop('command_name'), 1)])
681+
ordered_command.update(kwargs['command'])
682+
kwargs['command'] = ordered_command
683+
return target.command(**kwargs)
680684

681685
def __entityOperation_aggregate(self, target, *args, **kwargs):
682686
self.__raise_if_unsupported('aggregate', target, Database, Collection)

0 commit comments

Comments
 (0)