diff --git a/openpype/cli.py b/openpype/cli.py index 0597c387d0..6851541060 100644 --- a/openpype/cli.py +++ b/openpype/cli.py @@ -371,10 +371,15 @@ def run(script): "--app_variant", help="Provide specific app variant for test, empty for latest", default=None) -def runtests(folder, mark, pyargs, test_data_folder, persist, app_variant): +@click.option("-t", + "--timeout", + help="Provide specific timeout value for test case", + default=None) +def runtests(folder, mark, pyargs, test_data_folder, persist, app_variant, + timeout): """Run all automatic tests after proper initialization via start.py""" PypeCommands().run_tests(folder, mark, pyargs, test_data_folder, - persist, app_variant) + persist, app_variant, timeout) @main.command() diff --git a/openpype/pype_commands.py b/openpype/pype_commands.py index 47f5e7fcc0..9704b9198f 100644 --- a/openpype/pype_commands.py +++ b/openpype/pype_commands.py @@ -363,7 +363,7 @@ class PypeCommands: pass def run_tests(self, folder, mark, pyargs, - test_data_folder, persist, app_variant): + test_data_folder, persist, app_variant, timeout): """ Runs tests from 'folder' @@ -401,6 +401,9 @@ class PypeCommands: if app_variant: args.extend(["--app_variant", app_variant]) + if timeout: + args.extend(["--timeout", timeout]) + print("run_tests args: {}".format(args)) import pytest pytest.main(args) diff --git a/tests/integration/conftest.py b/tests/integration/conftest.py index 400c0dcc2a..aa850be1a6 100644 --- a/tests/integration/conftest.py +++ b/tests/integration/conftest.py @@ -19,6 +19,11 @@ def pytest_addoption(parser): help="Keep empty to locate latest installed variant or explicit" ) + parser.addoption( + "--timeout", action="store", default=None, + help="Overwrite default timeout" + ) + @pytest.fixture(scope="module") def test_data_folder(request): @@ -33,3 +38,8 @@ def persist(request): @pytest.fixture(scope="module") def app_variant(request): return request.config.getoption("--app_variant") + + +@pytest.fixture(scope="module") +def timeout(request): + return request.config.getoption("--timeout") diff --git a/tests/lib/testing_classes.py b/tests/lib/testing_classes.py index fa467acf9c..0a9da1aca8 100644 --- a/tests/lib/testing_classes.py +++ b/tests/lib/testing_classes.py @@ -293,13 +293,16 @@ class PublishTest(ModuleUnitTest): yield app_process @pytest.fixture(scope="module") - def publish_finished(self, dbcon, launched_app, download_test_data): + def publish_finished(self, dbcon, launched_app, download_test_data, + timeout): """Dummy fixture waiting for publish to finish""" import time time_start = time.time() + timeout = timeout or self.TIMEOUT + timeout = float(timeout) while launched_app.poll() is None: time.sleep(0.5) - if time.time() - time_start > self.TIMEOUT: + if time.time() - time_start > timeout: launched_app.terminate() raise ValueError("Timeout reached")