From 1b9bd95aa8612dadf9b20486cf39c7f6a897d1a6 Mon Sep 17 00:00:00 2001 From: Chuck Cadman <51368516+cdcadman@users.noreply.github.com> Date: Sat, 21 Dec 2024 10:36:09 -0800 Subject: [PATCH] Apply pytest warning filters to flask subprocess --- tests/server.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/tests/server.py b/tests/server.py index 07d318d..8f44de9 100644 --- a/tests/server.py +++ b/tests/server.py @@ -2,7 +2,17 @@ import subprocess as sp import sys import time +import tomllib from contextlib import contextmanager +from pathlib import Path + +TOML_FILE = Path(__file__).parent.absolute().parent / "pyproject.toml" + +WARNING_FILTERS = [] +for _filter in tomllib.loads(TOML_FILE.read_text())["tool"]["pytest"]["ini_options"][ + "filterwarnings" +]: + WARNING_FILTERS.extend(["-W", _filter]) TIMEOUT = 5 PORT = 5000 # this matches the port in the reverse proxy command for Android Virtual Device @@ -20,7 +30,9 @@ def close_server(server: sp.Popen, check_status=True): def get_server_url(maintenance_mode: bool = False): for _ in range(int(10 * TIMEOUT)): server = sp.Popen( - [sys.executable, "run_flask.py", str(PORT), str(maintenance_mode)], + [sys.executable] + + WARNING_FILTERS + + ["run_flask.py", str(PORT), str(maintenance_mode)], stderr=sp.PIPE, text=True, universal_newlines=True,