Skip to content

Commit c740118

Browse files
committed
Remove init_client
1 parent 124af83 commit c740118

File tree

2 files changed

+14
-18
lines changed

2 files changed

+14
-18
lines changed

test/asynchronous/unified_format.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ def _handle_placeholders(self, spec: dict, current: dict, path: str) -> Any:
257257
current[key] = self._handle_placeholders(spec, value, subpath)
258258
return current
259259

260-
async def _create_entity(self, entity_spec, uri=None, init_client=False):
260+
async def _create_entity(self, entity_spec, uri=None):
261261
if len(entity_spec) != 1:
262262
self.test.fail(f"Entity spec {entity_spec} did not contain exactly one top-level key")
263263

@@ -303,8 +303,7 @@ async def _create_entity(self, entity_spec, uri=None, init_client=False):
303303
if uri:
304304
kwargs["h"] = uri
305305
client = await self.test.async_rs_or_single_client(**kwargs)
306-
if init_client:
307-
await client.aconnect()
306+
await client.aconnect()
308307
self[spec["id"]] = client
309308
return
310309
elif entity_type == "database":
@@ -392,9 +391,9 @@ async def drop(self: AsyncGridFSBucket, *args: Any, **kwargs: Any) -> None:
392391

393392
self.test.fail(f"Unable to create entity of unknown type {entity_type}")
394393

395-
async def create_entities_from_spec(self, entity_spec, uri=None, init_client=False):
394+
async def create_entities_from_spec(self, entity_spec, uri=None):
396395
for spec in entity_spec:
397-
await self._create_entity(spec, uri=uri, init_client=init_client)
396+
await self._create_entity(spec, uri=uri)
398397

399398
def get_listener_for_client(self, client_name: str) -> EventListenerUtil:
400399
client = self[client_name]
@@ -1408,7 +1407,7 @@ async def run_scenario(self, spec, uri=None):
14081407
attempts = 3
14091408
for i in range(attempts):
14101409
try:
1411-
return await self._run_scenario(spec, uri, init_client=True)
1410+
return await self._run_scenario(spec, uri)
14121411
except (AssertionError, OperationFailure) as exc:
14131412
if isinstance(exc, OperationFailure) and (
14141413
_IS_SYNC or "failpoint" not in exc._message
@@ -1428,7 +1427,7 @@ async def run_scenario(self, spec, uri=None):
14281427
await self._run_scenario(spec, uri)
14291428
return None
14301429

1431-
async def _run_scenario(self, spec, uri=None, init_client=False):
1430+
async def _run_scenario(self, spec, uri=None):
14321431
# maybe skip test manually
14331432
self.maybe_skip_test(spec)
14341433

@@ -1446,7 +1445,7 @@ async def _run_scenario(self, spec, uri=None, init_client=False):
14461445
self._uri = uri
14471446
self.entity_map = EntityMapUtil(self)
14481447
await self.entity_map.create_entities_from_spec(
1449-
self.TEST_SPEC.get("createEntities", []), uri=uri, init_client=init_client
1448+
self.TEST_SPEC.get("createEntities", []), uri=uri
14501449
)
14511450
self._cluster_time = None
14521451
# process initialData

test/unified_format.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ def _handle_placeholders(self, spec: dict, current: dict, path: str) -> Any:
256256
current[key] = self._handle_placeholders(spec, value, subpath)
257257
return current
258258

259-
def _create_entity(self, entity_spec, uri=None, init_client=False):
259+
def _create_entity(self, entity_spec, uri=None):
260260
if len(entity_spec) != 1:
261261
self.test.fail(f"Entity spec {entity_spec} did not contain exactly one top-level key")
262262

@@ -302,8 +302,7 @@ def _create_entity(self, entity_spec, uri=None, init_client=False):
302302
if uri:
303303
kwargs["h"] = uri
304304
client = self.test.rs_or_single_client(**kwargs)
305-
if init_client:
306-
client._connect()
305+
client._connect()
307306
self[spec["id"]] = client
308307
return
309308
elif entity_type == "database":
@@ -391,9 +390,9 @@ def drop(self: GridFSBucket, *args: Any, **kwargs: Any) -> None:
391390

392391
self.test.fail(f"Unable to create entity of unknown type {entity_type}")
393392

394-
def create_entities_from_spec(self, entity_spec, uri=None, init_client=False):
393+
def create_entities_from_spec(self, entity_spec, uri=None):
395394
for spec in entity_spec:
396-
self._create_entity(spec, uri=uri, init_client=init_client)
395+
self._create_entity(spec, uri=uri)
397396

398397
def get_listener_for_client(self, client_name: str) -> EventListenerUtil:
399398
client = self[client_name]
@@ -1395,7 +1394,7 @@ def run_scenario(self, spec, uri=None):
13951394
attempts = 3
13961395
for i in range(attempts):
13971396
try:
1398-
return self._run_scenario(spec, uri, init_client=True)
1397+
return self._run_scenario(spec, uri)
13991398
except (AssertionError, OperationFailure) as exc:
14001399
if isinstance(exc, OperationFailure) and (
14011400
_IS_SYNC or "failpoint" not in exc._message
@@ -1415,7 +1414,7 @@ def run_scenario(self, spec, uri=None):
14151414
self._run_scenario(spec, uri)
14161415
return None
14171416

1418-
def _run_scenario(self, spec, uri=None, init_client=False):
1417+
def _run_scenario(self, spec, uri=None):
14191418
# maybe skip test manually
14201419
self.maybe_skip_test(spec)
14211420

@@ -1432,9 +1431,7 @@ def _run_scenario(self, spec, uri=None, init_client=False):
14321431
# process createEntities
14331432
self._uri = uri
14341433
self.entity_map = EntityMapUtil(self)
1435-
self.entity_map.create_entities_from_spec(
1436-
self.TEST_SPEC.get("createEntities", []), uri=uri, init_client=init_client
1437-
)
1434+
self.entity_map.create_entities_from_spec(self.TEST_SPEC.get("createEntities", []), uri=uri)
14381435
self._cluster_time = None
14391436
# process initialData
14401437
if "initialData" in self.TEST_SPEC:

0 commit comments

Comments
 (0)