Skip to content

Commit 49a79b2

Browse files
author
Andrei Neagu
committed
applied suggestion
1 parent 5d7e723 commit 49a79b2

File tree

1 file changed

+23
-12
lines changed

1 file changed

+23
-12
lines changed

services/web/server/tests/unit/with_dbs/02/test_projects_nodes_handler.py

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import asyncio
77
import re
88
from collections.abc import Awaitable, Callable
9+
from contextlib import suppress
910
from dataclasses import dataclass, field
1011
from datetime import datetime, timedelta
1112
from http import HTTPStatus
@@ -55,7 +56,9 @@
5556
from simcore_service_webserver.projects.models import ProjectDict
5657
from tenacity import (
5758
AsyncRetrying,
59+
RetryError,
5860
retry_if_exception_type,
61+
retry_unless_exception_type,
5962
stop_after_delay,
6063
wait_fixed,
6164
)
@@ -952,21 +955,29 @@ async def test_stop_node(
952955
status.HTTP_202_ACCEPTED if user_role == UserRole.GUEST else expected.accepted,
953956
)
954957

955-
async for attempt in AsyncRetrying(
956-
wait=wait_fixed(0.1),
957-
stop=stop_after_delay(5),
958-
retry=retry_if_exception_type(AssertionError),
959-
reraise=True,
960-
):
961-
with attempt:
962-
if error is None:
958+
if error is None:
959+
async for attempt in AsyncRetrying(
960+
wait=wait_fixed(0.1),
961+
stop=stop_after_delay(5),
962+
retry=retry_if_exception_type(AssertionError),
963+
reraise=True,
964+
):
965+
with attempt:
963966
mocked_dynamic_services_interface[
964967
"dynamic_scheduler.api.stop_dynamic_service"
965968
].assert_called_once()
966-
else:
967-
mocked_dynamic_services_interface[
968-
"dynamic_scheduler.api.stop_dynamic_service"
969-
].assert_not_called()
969+
else:
970+
with suppress(RetryError):
971+
async for attempt in AsyncRetrying(
972+
wait=wait_fixed(0.1),
973+
stop=stop_after_delay(5),
974+
retry=retry_unless_exception_type(AssertionError),
975+
reraise=True,
976+
):
977+
with attempt:
978+
mocked_dynamic_services_interface[
979+
"dynamic_scheduler.api.stop_dynamic_service"
980+
].assert_not_called()
970981

971982

972983
@pytest.fixture

0 commit comments

Comments
 (0)