Skip to content

Commit 26b1178

Browse files
committed
test_iteration regex
1 parent 8efa6ec commit 26b1178

File tree

2 files changed

+6
-12
lines changed

2 files changed

+6
-12
lines changed

test/asynchronous/test_client.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -243,12 +243,9 @@ async def test_getattr(self, async_client):
243243
assert "has no attribute '_does_not_exist'" in str(context.value)
244244

245245
async def test_iteration(self, async_client):
246-
if _IS_SYNC or sys.version_info < (3, 10):
247-
msg = "'AsyncMongoClient' object is not iterable"
248-
else:
249-
msg = "'AsyncMongoClient' object is not an async iterator"
246+
msg = "'AsyncMongoClient' object is not iterable"
250247

251-
with pytest.raises(TypeError, match="'AsyncMongoClient' object is not iterable"):
248+
with pytest.raises(TypeError, match=msg):
252249
for _ in async_client:
253250
break
254251

@@ -261,7 +258,7 @@ async def test_iteration(self, async_client):
261258
_ = await anext(async_client)
262259

263260
# 'next()' method fails
264-
with pytest.raises(TypeError, match="'AsyncMongoClient' object is not iterable"):
261+
with pytest.raises(TypeError, match=msg):
265262
_ = await async_client.anext()
266263

267264
# Do not implement typing.Iterable

test/test_client.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -240,12 +240,9 @@ def test_getattr(self, client):
240240
assert "has no attribute '_does_not_exist'" in str(context.value)
241241

242242
def test_iteration(self, client):
243-
if _IS_SYNC or sys.version_info < (3, 10):
244-
msg = "'MongoClient' object is not iterable"
245-
else:
246-
msg = "'MongoClient' object is not an async iterator"
243+
msg = "'MongoClient' object is not iterable"
247244

248-
with pytest.raises(TypeError, match="'MongoClient' object is not iterable"):
245+
with pytest.raises(TypeError, match=msg):
249246
for _ in client:
250247
break
251248

@@ -258,7 +255,7 @@ def test_iteration(self, client):
258255
_ = next(client)
259256

260257
# 'next()' method fails
261-
with pytest.raises(TypeError, match="'MongoClient' object is not iterable"):
258+
with pytest.raises(TypeError, match=msg):
262259
_ = client.next()
263260

264261
# Do not implement typing.Iterable

0 commit comments

Comments
 (0)