Skip to content

Commit 50529d6

Browse files
committed
Do not use shared fixture for internal sim abort test
1 parent f3e368f commit 50529d6

File tree

1 file changed

+34
-22
lines changed

1 file changed

+34
-22
lines changed

tests/refactor/test_run_class.py

Lines changed: 34 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import pytest
2+
import os
23
import pytest_mock
34
import time
45
import typing
@@ -512,28 +513,39 @@ def abort_callback(abort_run=trigger) -> None:
512513

513514

514515
@pytest.mark.run
515-
def test_abort_on_alert_python(create_plain_run: typing.Tuple[sv_run.Run, dict], mocker: pytest_mock.MockerFixture) -> None:
516-
abort_set = threading.Event()
517-
def testing_exit(status: int) -> None:
518-
abort_set.set()
519-
raise SystemExit(status)
520-
mocker.patch("os._exit", testing_exit)
521-
run, _ = create_plain_run
522-
run.config(resources_metrics_interval=1)
523-
run._heartbeat_interval = 1
524-
client = sv_cl.Client()
525-
i = 0
526-
527-
while True:
528-
time.sleep(1)
529-
if i == 4:
530-
client.abort_run(run._id, reason="testing abort")
531-
i += 1
532-
if abort_set.is_set() or i > 9:
533-
break
534-
535-
assert i < 7
536-
assert run._status == "terminated"
516+
def test_abort_on_alert_python(mocker: pytest_mock.MockerFixture) -> None:
517+
with simvue.Run() as run:
518+
run.config(suppress_errors=False)
519+
run.init(
520+
name="test_abort_on_alert_python",
521+
tags=["simvue_client_unit_tests"],
522+
folder="/simvue_unit_testing",
523+
visibility="tenant" if os.environ.get("CI") else None,
524+
retention_period="1 hour",
525+
timeout=60,
526+
no_color=True
527+
)
528+
529+
abort_set = threading.Event()
530+
def testing_exit(status: int) -> None:
531+
abort_set.set()
532+
raise SystemExit(status)
533+
mocker.patch("os._exit", testing_exit)
534+
run.config(resources_metrics_interval=1)
535+
run._heartbeat_interval = 1
536+
client = sv_cl.Client()
537+
i = 0
538+
539+
while True:
540+
time.sleep(1)
541+
if i == 4:
542+
client.abort_run(run._id, reason="testing abort")
543+
i += 1
544+
if abort_set.is_set() or i > 9:
545+
break
546+
547+
assert i < 7
548+
assert run._status == "terminated"
537549

538550

539551
@pytest.mark.run

0 commit comments

Comments
 (0)