Skip to content

Commit 57edcbc

Browse files
committed
more cleanup
1 parent dfa0639 commit 57edcbc

File tree

4 files changed

+25
-23
lines changed

4 files changed

+25
-23
lines changed

test/asynchronous/test_client.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ class AsyncClientUnitTest(AsyncUnitTest):
132132

133133
async def asyncSetUp(self) -> None:
134134
self.client = await self.async_rs_or_single_client(
135-
connect=True, serverSelectionTimeoutMS=100
135+
connect=False, serverSelectionTimeoutMS=100
136136
)
137137

138138
@pytest.fixture(autouse=True)
@@ -258,7 +258,7 @@ async def test_get_default_database(self):
258258
c = await self.async_rs_or_single_client(
259259
"mongodb://%s:%d/foo"
260260
% (await async_client_context.host, await async_client_context.port),
261-
connect=True,
261+
connect=False,
262262
)
263263
self.assertEqual(AsyncDatabase(c, "foo"), c.get_default_database())
264264
# Test that default doesn't override the URI value.
@@ -274,7 +274,7 @@ async def test_get_default_database(self):
274274

275275
c = await self.async_rs_or_single_client(
276276
"mongodb://%s:%d/" % (await async_client_context.host, await async_client_context.port),
277-
connect=True,
277+
connect=False,
278278
)
279279
self.assertEqual(AsyncDatabase(c, "foo"), c.get_default_database("foo"))
280280

@@ -292,14 +292,14 @@ async def test_get_default_database_with_authsource(self):
292292
await async_client_context.host,
293293
await async_client_context.port,
294294
)
295-
c = await self.async_rs_or_single_client(uri, connect=True)
295+
c = await self.async_rs_or_single_client(uri, connect=False)
296296
self.assertEqual(AsyncDatabase(c, "foo"), c.get_default_database())
297297

298298
async def test_get_database_default(self):
299299
c = await self.async_rs_or_single_client(
300300
"mongodb://%s:%d/foo"
301301
% (await async_client_context.host, await async_client_context.port),
302-
connect=True,
302+
connect=False,
303303
)
304304
self.assertEqual(AsyncDatabase(c, "foo"), c.get_database())
305305

@@ -317,7 +317,7 @@ async def test_get_database_default_with_authsource(self):
317317
await async_client_context.host,
318318
await async_client_context.port,
319319
)
320-
c = await self.async_rs_or_single_client(uri, connect=True)
320+
c = await self.async_rs_or_single_client(uri, connect=False)
321321
self.assertEqual(AsyncDatabase(c, "foo"), c.get_database())
322322

323323
async def test_primary_read_pref_with_tags(self):
@@ -817,7 +817,7 @@ async def test_init_disconnected(self):
817817
self.assertIsInstance(await c.is_primary, bool)
818818
c = await self.async_rs_or_single_client(connect=False)
819819
self.assertIsInstance(await c.is_mongos, bool)
820-
c = await self.async_rs_or_single_client(connect=True)
820+
c = await self.async_rs_or_single_client(connect=False)
821821
self.assertIsInstance(c.options.pool_options.max_pool_size, int)
822822
self.assertIsInstance(c.nodes, frozenset)
823823

@@ -850,12 +850,12 @@ async def test_init_disconnected_with_auth(self):
850850

851851
async def test_equality(self):
852852
seed = "{}:{}".format(*list(self.client._topology_settings.seeds)[0])
853-
c = await self.async_rs_or_single_client(seed, connect=True)
853+
c = await self.async_rs_or_single_client(seed, connect=False)
854854
self.assertEqual(async_client_context.client, c)
855855
# Explicitly test inequality
856856
self.assertFalse(async_client_context.client != c)
857857

858-
c = await self.async_rs_or_single_client("invalid.com", connect=True)
858+
c = await self.async_rs_or_single_client("invalid.com", connect=False)
859859
self.assertNotEqual(async_client_context.client, c)
860860
self.assertTrue(async_client_context.client != c)
861861

@@ -877,9 +877,9 @@ async def test_equality(self):
877877

878878
async def test_hashable(self):
879879
seed = "{}:{}".format(*list(self.client._topology_settings.seeds)[0])
880-
c = await self.async_rs_or_single_client(seed, connect=True)
880+
c = await self.async_rs_or_single_client(seed, connect=False)
881881
self.assertIn(c, {async_client_context.client})
882-
c = await self.async_rs_or_single_client("invalid.com", connect=True)
882+
c = await self.async_rs_or_single_client("invalid.com", connect=False)
883883
self.assertNotIn(c, {async_client_context.client})
884884

885885
async def test_host_w_port(self):
@@ -1618,7 +1618,7 @@ def init(self, *args):
16181618
finally:
16191619
ServerHeartbeatStartedEvent.__init__ = old_init # type: ignore
16201620

1621-
async def test_small_heartbeat_frequency_ms(self):
1621+
def test_small_heartbeat_frequency_ms(self):
16221622
uri = "mongodb://example/?heartbeatFrequencyMS=499"
16231623
with self.assertRaises(ConfigurationError) as context:
16241624
AsyncMongoClient(uri)

test/asynchronous/unified_format.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1354,6 +1354,7 @@ def format_logs(log_list):
13541354
)
13551355
for expected_msg, actual_msg in zip(client["messages"], actual_logs):
13561356
expected_data, actual_data = expected_msg.pop("data"), actual_msg.pop("data")
1357+
13571358
if "failureIsRedacted" in expected_msg:
13581359
self.assertIn("failure", actual_data)
13591360
should_redact = expected_msg.pop("failureIsRedacted")

test/test_client.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ class ClientUnitTest(UnitTest):
130130
client: MongoClient
131131

132132
def setUp(self) -> None:
133-
self.client = self.rs_or_single_client(connect=True, serverSelectionTimeoutMS=100)
133+
self.client = self.rs_or_single_client(connect=False, serverSelectionTimeoutMS=100)
134134

135135
@pytest.fixture(autouse=True)
136136
def inject_fixtures(self, caplog):
@@ -254,7 +254,7 @@ def test_iteration(self):
254254
def test_get_default_database(self):
255255
c = self.rs_or_single_client(
256256
"mongodb://%s:%d/foo" % (client_context.host, client_context.port),
257-
connect=True,
257+
connect=False,
258258
)
259259
self.assertEqual(Database(c, "foo"), c.get_default_database())
260260
# Test that default doesn't override the URI value.
@@ -270,7 +270,7 @@ def test_get_default_database(self):
270270

271271
c = self.rs_or_single_client(
272272
"mongodb://%s:%d/" % (client_context.host, client_context.port),
273-
connect=True,
273+
connect=False,
274274
)
275275
self.assertEqual(Database(c, "foo"), c.get_default_database("foo"))
276276

@@ -288,13 +288,13 @@ def test_get_default_database_with_authsource(self):
288288
client_context.host,
289289
client_context.port,
290290
)
291-
c = self.rs_or_single_client(uri, connect=True)
291+
c = self.rs_or_single_client(uri, connect=False)
292292
self.assertEqual(Database(c, "foo"), c.get_default_database())
293293

294294
def test_get_database_default(self):
295295
c = self.rs_or_single_client(
296296
"mongodb://%s:%d/foo" % (client_context.host, client_context.port),
297-
connect=True,
297+
connect=False,
298298
)
299299
self.assertEqual(Database(c, "foo"), c.get_database())
300300

@@ -312,7 +312,7 @@ def test_get_database_default_with_authsource(self):
312312
client_context.host,
313313
client_context.port,
314314
)
315-
c = self.rs_or_single_client(uri, connect=True)
315+
c = self.rs_or_single_client(uri, connect=False)
316316
self.assertEqual(Database(c, "foo"), c.get_database())
317317

318318
def test_primary_read_pref_with_tags(self):
@@ -792,7 +792,7 @@ def test_init_disconnected(self):
792792
self.assertIsInstance(c.is_primary, bool)
793793
c = self.rs_or_single_client(connect=False)
794794
self.assertIsInstance(c.is_mongos, bool)
795-
c = self.rs_or_single_client(connect=True)
795+
c = self.rs_or_single_client(connect=False)
796796
self.assertIsInstance(c.options.pool_options.max_pool_size, int)
797797
self.assertIsInstance(c.nodes, frozenset)
798798

@@ -825,12 +825,12 @@ def test_init_disconnected_with_auth(self):
825825

826826
def test_equality(self):
827827
seed = "{}:{}".format(*list(self.client._topology_settings.seeds)[0])
828-
c = self.rs_or_single_client(seed, connect=True)
828+
c = self.rs_or_single_client(seed, connect=False)
829829
self.assertEqual(client_context.client, c)
830830
# Explicitly test inequality
831831
self.assertFalse(client_context.client != c)
832832

833-
c = self.rs_or_single_client("invalid.com", connect=True)
833+
c = self.rs_or_single_client("invalid.com", connect=False)
834834
self.assertNotEqual(client_context.client, c)
835835
self.assertTrue(client_context.client != c)
836836

@@ -852,9 +852,9 @@ def test_equality(self):
852852

853853
def test_hashable(self):
854854
seed = "{}:{}".format(*list(self.client._topology_settings.seeds)[0])
855-
c = self.rs_or_single_client(seed, connect=True)
855+
c = self.rs_or_single_client(seed, connect=False)
856856
self.assertIn(c, {client_context.client})
857-
c = self.rs_or_single_client("invalid.com", connect=True)
857+
c = self.rs_or_single_client("invalid.com", connect=False)
858858
self.assertNotIn(c, {client_context.client})
859859

860860
def test_host_w_port(self):

test/unified_format.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1341,6 +1341,7 @@ def format_logs(log_list):
13411341
)
13421342
for expected_msg, actual_msg in zip(client["messages"], actual_logs):
13431343
expected_data, actual_data = expected_msg.pop("data"), actual_msg.pop("data")
1344+
13441345
if "failureIsRedacted" in expected_msg:
13451346
self.assertIn("failure", actual_data)
13461347
should_redact = expected_msg.pop("failureIsRedacted")

0 commit comments

Comments
 (0)