Skip to content

Commit

Permalink
Fix test failures (#1973)
Browse files Browse the repository at this point in the history
  • Loading branch information
NoahStapp authored Oct 25, 2024
1 parent e736221 commit 2d98fb1
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 9 deletions.
2 changes: 1 addition & 1 deletion test/asynchronous/test_auth_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
sys.path[0:0] = [""]

from test import unittest
from test.unified_format import generate_test_classes
from test.asynchronous.unified_format import generate_test_classes

from pymongo import AsyncMongoClient
from pymongo.asynchronous.auth_oidc import OIDCCallback
Expand Down
2 changes: 1 addition & 1 deletion test/asynchronous/test_change_stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
async_client_context,
unittest,
)
from test.unified_format import generate_test_classes
from test.asynchronous.unified_format import generate_test_classes
from test.utils import (
AllowListEventListener,
EventListener,
Expand Down
2 changes: 1 addition & 1 deletion test/asynchronous/test_connection_logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
sys.path[0:0] = [""]

from test import unittest
from test.unified_format import generate_test_classes
from test.asynchronous.unified_format import generate_test_classes

_IS_SYNC = False

Expand Down
6 changes: 6 additions & 0 deletions test/asynchronous/test_create_entities.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ async def test_store_events_as_entities(self):
self.assertGreater(len(final_entity_map["events1"]), 0)
for event in final_entity_map["events1"]:
self.assertIn("PoolCreatedEvent", event["name"])
if self.scenario_runner.mongos_clients:
for client in self.scenario_runner.mongos_clients:
await client.close()

async def test_store_all_others_as_entities(self):
self.scenario_runner = UnifiedSpecTestMixinV1()
Expand Down Expand Up @@ -122,6 +125,9 @@ async def test_store_all_others_as_entities(self):
self.assertEqual(entity_map["failures"], [])
self.assertEqual(entity_map["successes"], 2)
self.assertEqual(entity_map["iterations"], 5)
if self.scenario_runner.mongos_clients:
for client in self.scenario_runner.mongos_clients:
await client.close()


if __name__ == "__main__":
Expand Down
2 changes: 1 addition & 1 deletion test/asynchronous/test_crud_unified.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
sys.path[0:0] = [""]

from test import unittest
from test.unified_format import generate_test_classes
from test.asynchronous.unified_format import generate_test_classes

_IS_SYNC = False

Expand Down
2 changes: 1 addition & 1 deletion test/asynchronous/test_encryption.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
unittest,
)
from test.asynchronous.test_bulk import AsyncBulkTestBase
from test.asynchronous.unified_format import generate_test_classes
from test.asynchronous.utils_spec_runner import AsyncSpecRunner
from test.helpers import (
AWS_CREDS,
Expand All @@ -56,7 +57,6 @@
KMIP_CREDS,
LOCAL_MASTER_KEY,
)
from test.unified_format import generate_test_classes
from test.utils import (
AllowListEventListener,
OvertCommandListener,
Expand Down
2 changes: 0 additions & 2 deletions test/asynchronous/unified_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,6 @@ async def _create_entity(self, entity_spec, uri=None):
kwargs["h"] = uri
client = await self.test.async_rs_or_single_client(**kwargs)
self[spec["id"]] = client
self.test.addAsyncCleanup(client.close)
return
elif entity_type == "database":
client = self[spec["client"]]
Expand Down Expand Up @@ -1037,7 +1036,6 @@ async def _testOperation_targetedFailPoint(self, spec):
)

client = await self.async_single_client("{}:{}".format(*session._pinned_address))
self.addAsyncCleanup(client.close)
await self.__set_fail_point(client=client, command_args=spec["failPoint"])

async def _testOperation_createEntities(self, spec):
Expand Down
6 changes: 6 additions & 0 deletions test/test_create_entities.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ def test_store_events_as_entities(self):
self.assertGreater(len(final_entity_map["events1"]), 0)
for event in final_entity_map["events1"]:
self.assertIn("PoolCreatedEvent", event["name"])
if self.scenario_runner.mongos_clients:
for client in self.scenario_runner.mongos_clients:
client.close()

def test_store_all_others_as_entities(self):
self.scenario_runner = UnifiedSpecTestMixinV1()
Expand Down Expand Up @@ -122,6 +125,9 @@ def test_store_all_others_as_entities(self):
self.assertEqual(entity_map["failures"], [])
self.assertEqual(entity_map["successes"], 2)
self.assertEqual(entity_map["iterations"], 5)
if self.scenario_runner.mongos_clients:
for client in self.scenario_runner.mongos_clients:
client.close()


if __name__ == "__main__":
Expand Down
2 changes: 0 additions & 2 deletions test/unified_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,6 @@ def _create_entity(self, entity_spec, uri=None):
kwargs["h"] = uri
client = self.test.rs_or_single_client(**kwargs)
self[spec["id"]] = client
self.test.addCleanup(client.close)
return
elif entity_type == "database":
client = self[spec["client"]]
Expand Down Expand Up @@ -1028,7 +1027,6 @@ def _testOperation_targetedFailPoint(self, spec):
)

client = self.single_client("{}:{}".format(*session._pinned_address))
self.addCleanup(client.close)
self.__set_fail_point(client=client, command_args=spec["failPoint"])

def _testOperation_createEntities(self, spec):
Expand Down

0 comments on commit 2d98fb1

Please sign in to comment.