You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iggy.apache.org by ri...@apache.org on 2026/08/31 07:37:48 UTC
(iggy) 08/11: fix test
This is an automated email from the ASF dual-hosted git repository.
slbotbm pushed a commit to branch feat/add-python-stream-management-functions
in repository https://gitbox.apache.org/repos/asf/iggy.git
commit af3e0aabd52fe9325d8d0b5940fc1629de02eafc
Author: Rimuksh Kansal <ni...@gmail.com>
AuthorDate: Sun Aug 16 18:08:45 2026 +0900
fix test
---
foreign/python/tests/conftest.py | 34 +++++++++++++++-------------------
foreign/python/tests/test_stream.py | 10 ++++++----
2 files changed, 21 insertions(+), 23 deletions(-)
diff --git a/foreign/python/tests/conftest.py b/foreign/python/tests/conftest.py
index 5c8d15a1c..734054069 100644
--- a/foreign/python/tests/conftest.py
+++ b/foreign/python/tests/conftest.py
@@ -71,13 +71,7 @@ async def iggy_client() -> IggyClient:
@pytest.fixture
-def issued_names() -> set[str]:
- """Return names created by unique_name in one test."""
- return set()
-
-
-@pytest.fixture
-def unique_name(issued_names: set[str]):
+def unique_name():
"""Return a factory for generating unique test names."""
def make_name(
@@ -108,27 +102,29 @@ def unique_name(issued_names: set[str]):
+ min_suffix_bytes
)
suffix = "".join(secrets.choice(alphabet) for _ in range(suffix_bytes))
- name = f"{prefix}{suffix}"
- issued_names.add(name)
- return name
+ return f"{prefix}{suffix}"
return make_name
-@pytest.fixture(autouse=True)
+@pytest.fixture(scope="function", autouse=True)
async def cleanup_streams(
- request: pytest.FixtureRequest, issued_names: set[str]
+ request: pytest.FixtureRequest,
) -> AsyncGenerator[None, None]:
"""Delete streams created by the current test."""
- yield
-
- if not issued_names:
+ if "iggy_client" not in request.fixturenames:
+ yield
return
- client = request.getfixturevalue("iggy_client")
- for name in issued_names:
- with contextlib.suppress(RuntimeError):
- await client.delete_stream(name)
+ client: IggyClient = request.getfixturevalue("iggy_client")
+ existing_stream_ids = {stream.id for stream in await client.get_streams()}
+
+ yield
+
+ for stream in await client.get_streams():
+ if stream.id not in existing_stream_ids:
+ with contextlib.suppress(RuntimeError):
+ await client.delete_stream(stream.id)
@pytest.fixture(scope="session", autouse=True)
diff --git a/foreign/python/tests/test_stream.py b/foreign/python/tests/test_stream.py
index 24e55e66c..a44dec183 100644
--- a/foreign/python/tests/test_stream.py
+++ b/foreign/python/tests/test_stream.py
@@ -339,10 +339,12 @@ class TestUpdateStream:
await iggy_client.create_stream(stream_name)
await iggy_client.update_stream(stream_id=stream_name, name=new_name)
-
- renamed = await iggy_client.get_stream(new_name)
- assert renamed is not None
- assert renamed.name == new_name
+ try:
+ renamed = await iggy_client.get_stream(new_name)
+ assert renamed is not None
+ assert renamed.name == new_name
+ finally:
+ await iggy_client.delete_stream(new_name)
@pytest.mark.asyncio
@pytest.mark.parametrize(