Skip to content

Commit

Permalink
test_iteration regex
Browse files Browse the repository at this point in the history
  • Loading branch information
NoahStapp committed Jan 24, 2025
1 parent 8efa6ec commit 26b1178
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
9 changes: 3 additions & 6 deletions test/asynchronous/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,12 +243,9 @@ async def test_getattr(self, async_client):
assert "has no attribute '_does_not_exist'" in str(context.value)

async def test_iteration(self, async_client):
if _IS_SYNC or sys.version_info < (3, 10):
msg = "'AsyncMongoClient' object is not iterable"
else:
msg = "'AsyncMongoClient' object is not an async iterator"
msg = "'AsyncMongoClient' object is not iterable"

with pytest.raises(TypeError, match="'AsyncMongoClient' object is not iterable"):
with pytest.raises(TypeError, match=msg):
for _ in async_client:
break

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

# 'next()' method fails
with pytest.raises(TypeError, match="'AsyncMongoClient' object is not iterable"):
with pytest.raises(TypeError, match=msg):
_ = await async_client.anext()

# Do not implement typing.Iterable
Expand Down
9 changes: 3 additions & 6 deletions test/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,12 +240,9 @@ def test_getattr(self, client):
assert "has no attribute '_does_not_exist'" in str(context.value)

def test_iteration(self, client):
if _IS_SYNC or sys.version_info < (3, 10):
msg = "'MongoClient' object is not iterable"
else:
msg = "'MongoClient' object is not an async iterator"
msg = "'MongoClient' object is not iterable"

with pytest.raises(TypeError, match="'MongoClient' object is not iterable"):
with pytest.raises(TypeError, match=msg):
for _ in client:
break

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

# 'next()' method fails
with pytest.raises(TypeError, match="'MongoClient' object is not iterable"):
with pytest.raises(TypeError, match=msg):
_ = client.next()

# Do not implement typing.Iterable
Expand Down

0 comments on commit 26b1178

Please sign in to comment.