mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 21:04:40 +01:00
OP-2042 - added test_data_folder to command line
This commit is contained in:
parent
e680a362b7
commit
2f2116b4bd
4 changed files with 31 additions and 15 deletions
|
|
@ -356,9 +356,13 @@ def run(script):
|
|||
"--pyargs",
|
||||
help="Run tests from package",
|
||||
default=None)
|
||||
def runtests(folder, mark, pyargs):
|
||||
@click.option("-t",
|
||||
"--test_data_folder",
|
||||
help="Unzipped directory path of test file",
|
||||
default=None)
|
||||
def runtests(folder, mark, pyargs, test_data_folder):
|
||||
"""Run all automatic tests after proper initialization via start.py"""
|
||||
PypeCommands().run_tests(folder, mark, pyargs)
|
||||
PypeCommands().run_tests(folder, mark, pyargs, test_data_folder)
|
||||
|
||||
|
||||
@main.command()
|
||||
|
|
|
|||
|
|
@ -341,7 +341,7 @@ class PypeCommands:
|
|||
def validate_jsons(self):
|
||||
pass
|
||||
|
||||
def run_tests(self, folder, mark, pyargs):
|
||||
def run_tests(self, folder, mark, pyargs, test_data_folder):
|
||||
"""
|
||||
Runs tests from 'folder'
|
||||
|
||||
|
|
@ -349,26 +349,26 @@ class PypeCommands:
|
|||
folder (str): relative path to folder with tests
|
||||
mark (str): label to run tests marked by it (slow etc)
|
||||
pyargs (str): package path to test
|
||||
test_data_folder (str): url to unzipped folder of test data
|
||||
"""
|
||||
print("run_tests")
|
||||
import subprocess
|
||||
|
||||
if folder:
|
||||
folder = " ".join(list(folder))
|
||||
else:
|
||||
folder = "../tests"
|
||||
|
||||
mark_str = pyargs_str = ''
|
||||
# disable warnings and show captured stdout even if success
|
||||
args = ["--disable-pytest-warnings", "-rP", folder]
|
||||
|
||||
if mark:
|
||||
mark_str = "-m {}".format(mark)
|
||||
args.extend(["-m", mark])
|
||||
|
||||
if pyargs:
|
||||
pyargs_str = "--pyargs {}".format(pyargs)
|
||||
args.extend(["--pyargs", pyargs])
|
||||
|
||||
# disable warnings and show captured stdout even if success
|
||||
args = ["--disable-pytest-warnings", "-rP"]
|
||||
if test_data_folder:
|
||||
args.extend(["--test_data_folder", test_data_folder])
|
||||
|
||||
args += [folder, mark_str, pyargs_str]
|
||||
print("run_tests args: {}".format(args))
|
||||
import pytest
|
||||
pytest.main(args)
|
||||
|
|
|
|||
12
tests/integration/conftest.py
Normal file
12
tests/integration/conftest.py
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
import pytest
|
||||
|
||||
def pytest_addoption(parser):
|
||||
parser.addoption(
|
||||
"--test_data_folder", action="store", default=None,
|
||||
help="Provide url of a folder of unzipped test file"
|
||||
)
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def test_data_folder(request):
|
||||
return request.config.getoption("--test_data_folder")
|
||||
|
|
@ -58,10 +58,10 @@ class ModuleUnitTest(BaseTest):
|
|||
m.undo()
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def download_test_data(self):
|
||||
if self.TEST_DATA_FOLDER:
|
||||
print("Using existing folder {}".format(self.TEST_DATA_FOLDER))
|
||||
yield self.TEST_DATA_FOLDER
|
||||
def download_test_data(self, test_data_folder):
|
||||
if test_data_folder:
|
||||
print("Using existing folder {}".format(test_data_folder))
|
||||
yield test_data_folder
|
||||
else:
|
||||
tmpdir = tempfile.mkdtemp()
|
||||
for test_file in self.TEST_FILES:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue