Skip to content

Commit 06924cb

Browse files
authored
PYTHON-2489 Fix "no server" test suite, fix unified test runCommand (#543)
1 parent dad9813 commit 06924cb

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
@@ -920,14 +920,15 @@ def teardown():
920920
if garbage:
921921
assert False, '\n'.join(garbage)
922922
c = client_context.client
923-
if c and not client_context.is_data_lake:
924-
c.drop_database("pymongo-pooling-tests")
925-
c.drop_database("pymongo_test")
926-
c.drop_database("pymongo_test1")
927-
c.drop_database("pymongo_test2")
928-
c.drop_database("pymongo_test_mike")
929-
c.drop_database("pymongo_test_bernie")
930-
c.close()
923+
if c:
924+
if not client_context.is_data_lake:
925+
c.drop_database("pymongo-pooling-tests")
926+
c.drop_database("pymongo_test")
927+
c.drop_database("pymongo_test1")
928+
c.drop_database("pymongo_test2")
929+
c.drop_database("pymongo_test_mike")
930+
c.drop_database("pymongo_test_bernie")
931+
c.close()
931932

932933
# Jython does not support gc.get_objects.
933934
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)