From 21f62e0c09f3a5b5ce81fa8b7254cc98faf194e0 Mon Sep 17 00:00:00 2001 From: Thomas Miedema Date: Fri, 6 May 2022 14:25:17 +0200 Subject: [PATCH] Fix test: move asserts out of the `with` body `next_node` raises, so the `assert`s would never run --- test/discovery_test.py | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/test/discovery_test.py b/test/discovery_test.py index 64cdd1c..58d7e10 100644 --- a/test/discovery_test.py +++ b/test/discovery_test.py @@ -11,7 +11,6 @@ DiscoveryRetryPolicy, NodeService, NodeState, - SingleNodeDiscovery, StaticSeedFinder, Stats, fetch_new_gossip, @@ -251,23 +250,19 @@ async def wait(self, seed): seed = NodeService("1.2.3.4", 2113, None) retry = always_fail() - gossip = data.make_gossip("2.3.4.5") + discoverer = ClusterDiscovery(StaticSeedFinder([seed]), retry, None) with aioresponses() as mock: - successful_discoverer = ClusterDiscovery(StaticSeedFinder([seed]), retry, None) - mock.get("http://1.2.3.4:2113/gossip", status=500) - mock.get("http://1.2.3.4:2113/gossip", payload=gossip) with pytest.raises(DiscoveryFailed): - assert await successful_discoverer.next_node() == NodeService( - "2.3.4.5", 1113, None - ) - stats = retry.stats[seed] - - assert stats.attempts == 1 - assert stats.successes == 0 - assert stats.failures == 1 - assert stats.consecutive_failures == 1 + await discoverer.next_node() + + stats = retry.stats[seed] + + assert stats.attempts == 1 + assert stats.successes == 0 + assert stats.failures == 1 + assert stats.consecutive_failures == 1 @pytest.mark.asyncio