Skip to content

Commit f46ea0d

Browse files
Using dynamic side effects
1 parent 0d8fe80 commit f46ea0d

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

tests_integration/producer/test_inbound_producer.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,15 @@ def test_publish_inbound_message_publishes_to_retries_and_succeeds_on_last_attem
109109
test_client: TestClient,
110110
captured_logs: list[MutableMapping[str, Any]],
111111
):
112-
mock_publish_to_outbound.side_effect = [
113-
ValueError("First failure"),
114-
ValueError("Second failure"),
115-
None,
116-
]
112+
async def publish_outbound_side_effect_logic(*args, **kwargs):
113+
if mock_publish_to_outbound.call_count == 1:
114+
raise ValueError("First failure")
115+
if mock_publish_to_outbound.call_count == 2:
116+
raise TypeError("Second failure")
117+
# Call 3 and all future calls fall back to returning None
118+
return None
119+
120+
mock_publish_to_outbound.side_effect = publish_outbound_side_effect_logic
117121

118122
sample1: Sample = Sample(
119123
id=uuid.uuid4(),

0 commit comments

Comments
 (0)