Skip to content

Commit

Permalink
test: Add xfail test for reusing messages generator after disconnecti…
Browse files Browse the repository at this point in the history
…on; #268
  • Loading branch information
empicano committed Feb 18, 2024
1 parent cabc9b0 commit 9a1cbb1
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,17 +367,20 @@ async def test_aexit_client_is_already_disconnected_failure() -> None:
await client.__aexit__(None, None, None)


@pytest.mark.xfail
@pytest.mark.network
async def test_messages_generator_is_reusable() -> None:
"""Test that the messages generator is reusable and returns no duplicates."""
"""Test that the messages generator is reusable after dis- and reconnection."""
topic = TOPIC_PREFIX + "test_messages_generator_is_reusable"
async with Client(HOSTNAME) as client:
client = Client(HOSTNAME)
async with client:
client._disconnected.set_result(None)
with pytest.raises(MqttError):
# TODO(felix): Switch to anext function from Python 3.10
await client.messages.__anext__()
async with client:
await client.subscribe(topic)
await client.publish(topic, "foo")
await client.publish(topic, "bar")
async for message in client.messages:
assert message.payload == b"foo"
break
async for message in client.messages:
assert message.payload == b"bar"
break
# TODO(felix): Switch to anext function from Python 3.10
message = await client.messages.__anext__()
assert message.payload == b"foo"

0 comments on commit 9a1cbb1

Please sign in to comment.