Skip to content

Commit

Permalink
Run server startup on every test
Browse files Browse the repository at this point in the history
  • Loading branch information
odjuricicTT committed Nov 13, 2024
1 parent 8f89cdb commit 63f7725
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions tools/explorer/test/run_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def execute_command(model_path, settings):
assert False


@pytest.fixture(scope="session", autouse=True)
@pytest.fixture(scope="function", autouse=True)
def start_server(request):
server_thread = multiprocessing.Process(
target=model_explorer.visualize,
Expand All @@ -59,11 +59,18 @@ def start_server(request):
if response.status_code == 200:
break
except requests.ConnectionError:
pass
finally:
time.sleep(0.1)
else:
raise RuntimeError("Server did not start within the expected time")

request.addfinalizer(lambda: server_thread.terminate())
# Terminate the server and wait for it to finish.
def server_shutdown():
server_thread.terminate()
server_thread.join()

request.addfinalizer(server_shutdown)


@pytest.mark.parametrize("model_path", get_test_files(TEST_LOAD_MODEL_PATHS))
Expand Down

0 comments on commit 63f7725

Please sign in to comment.