diff --git a/tests/python/shared/fixtures/init.py b/tests/python/shared/fixtures/init.py index d0a68b94..77c7e702 100644 --- a/tests/python/shared/fixtures/init.py +++ b/tests/python/shared/fixtures/init.py @@ -259,12 +259,21 @@ def start_services(rebuild=False): docker_cp(CVAT_DB_DIR / "data.json", f"{PREFIX}_cvat_server_1:/tmp/data.json") -def pytest_sessionstart(session): +def pytest_sessionstart(session: pytest.Session) -> None: stop = session.config.getoption("--stop-services") start = session.config.getoption("--start-services") rebuild = session.config.getoption("--rebuild") cleanup = session.config.getoption("--cleanup") dumpdb = session.config.getoption("--dumpdb") + + if session.config.getoption("--collect-only"): + if any((stop, start, rebuild, cleanup, dumpdb)): + raise Exception( + """--collect-only is not compatible with any of the other options: + --stop-services --start-services --rebuild --cleanup --dumpdb""" + ) + return # don't need to start the services to collect tests + platform = session.config.getoption("--platform") if platform == "kube" and any((stop, start, rebuild, cleanup, dumpdb)): @@ -338,7 +347,10 @@ def pytest_sessionstart(session): ) -def pytest_sessionfinish(session, exitstatus): +def pytest_sessionfinish(session: pytest.Session, exitstatus: int) -> None: + if session.config.getoption("--collect-only"): + return + platform = session.config.getoption("--platform") if platform == "local":