Skip to content

Commit 9b75437

Browse files
Fix notifier test setup hanging on error
1 parent aed1fbe commit 9b75437

File tree

1 file changed

+4
-13
lines changed

1 file changed

+4
-13
lines changed

tests/test_notifier.py

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -36,19 +36,10 @@ def start_server():
3636
flask_process = Process(target=run_server, args=(queue,))
3737
flask_process.start()
3838

39-
timeout = 60 # wait maximum of 60 seconds
40-
while True:
41-
try:
42-
response = requests.get(WEBHOOK_SERVER_URL, timeout=1_000)
43-
if response.status_code == 200: # Or another condition
44-
break
45-
except (requests.ConnectionError, socket.error):
46-
time.sleep(1) # wait for 1 second before trying again
47-
timeout -= 1
48-
if timeout == 0:
49-
pytest.fail("Server did not start in the expected time")
50-
51-
yield # This is where the testing happens.
39+
response = requests.get(WEBHOOK_SERVER_URL, timeout=3)
40+
response.raise_for_status()
41+
42+
yield
5243

5344
flask_process.terminate()
5445

0 commit comments

Comments
 (0)