mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 21:04:40 +01:00
Added timeout to command line arguments
This commit is contained in:
parent
cc9fa259dd
commit
c6805d5b5a
4 changed files with 26 additions and 5 deletions
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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")
|
||||
|
|
|
|||
|
|
@ -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")
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue