diff --git a/openpype/pype_commands.py b/openpype/pype_commands.py index c309ee8c09..5288749e8b 100644 --- a/openpype/pype_commands.py +++ b/openpype/pype_commands.py @@ -268,13 +268,19 @@ class PypeCommands: """ print("run_tests") import subprocess - folder = folder or "../tests" + + if folder: + folder = " ".join(list(folder)) + else: + folder = "../tests" + mark_str = pyargs_str = '' if mark: - mark_str = "- m {}".format(mark) + mark_str = "-m {}".format(mark) if pyargs: pyargs_str = "--pyargs {}".format(pyargs) - subprocess.run("pytest {} {} {}".format(folder, mark_str, pyargs_str)) - + cmd = "pytest {} {} {}".format(folder, mark_str, pyargs_str) + print("Running {}".format(cmd)) + subprocess.run(cmd) diff --git a/tests/README.md b/tests/README.md index 727b89a86e..6317b2ab3c 100644 --- a/tests/README.md +++ b/tests/README.md @@ -1,7 +1,7 @@ Automatic tests for OpenPype ============================ Structure: -- integration - end to end tests, slow +- integration - end to end tests, slow (see README.md in the integration folder for more info) - openpype/modules/MODULE_NAME - structure follow directory structure in code base - fixture - sample data `(MongoDB dumps, test files etc.)` - `tests.py` - single or more pytest files for MODULE_NAME @@ -10,3 +10,16 @@ Structure: - fixture - `tests.py` +How to run: +---------- +- single test class could be run by PyCharm and its pytest runner directly +- OR +- use Openpype command 'runtests' from command line +-- `${OPENPYPE_ROOT}/start.py runtests` + +By default, this command will run all tests in ${OPENPYPE_ROOT}/tests. + +Specific location could be provided to this command as an argument, either as absolute path, or relative path to ${OPENPYPE_ROOT}. +(eg. `${OPENPYPE_ROOT}/start.py runtests ../tests/integration`) will trigger only tests in `integration` folder. + +See `${OPENPYPE_ROOT}/cli.py:runtests` for other arguments. diff --git a/tests/integration/hosts/maya/test_publish_in_maya.py b/tests/integration/hosts/maya/test_publish_in_maya.py index b9c63651f1..c178a6687e 100644 --- a/tests/integration/hosts/maya/test_publish_in_maya.py +++ b/tests/integration/hosts/maya/test_publish_in_maya.py @@ -1,8 +1,6 @@ import pytest -import sys import os import shutil -import glob from tests.lib.testing_classes import PublishTest diff --git a/tests/lib/file_handler.py b/tests/lib/file_handler.py index 98e14b0541..ee3abc6ecb 100644 --- a/tests/lib/file_handler.py +++ b/tests/lib/file_handler.py @@ -193,11 +193,10 @@ class RemoteFileHandler: urllib.request.Request(url, headers={"User-Agent": USER_AGENT})) \ as response: - for chunk in iter(lambda: response.read(chunk_size), - ""): - if not chunk: - break - fh.write(chunk) + for chunk in iter(lambda: response.read(chunk_size), ""): + if not chunk: + break + fh.write(chunk) @staticmethod def _get_redirect_url(url, max_hops): @@ -218,7 +217,7 @@ class RemoteFileHandler: ) @staticmethod - def _get_confirm_token(response): # type: ignore[name-defined] + def _get_confirm_token(response): for key, value in response.cookies.items(): if key.startswith('download_warning'): return value @@ -227,7 +226,7 @@ class RemoteFileHandler: @staticmethod def _save_response_content( - response_gen, destination, # type: ignore[name-defined] + response_gen, destination, ): with open(destination, "wb") as f: pbar = enlighten.Counter( @@ -241,7 +240,7 @@ class RemoteFileHandler: pbar.close() @staticmethod - def _quota_exceeded(first_chunk): # type: ignore[name-defined] + def _quota_exceeded(first_chunk): try: return "Google Drive - Quota exceeded" in first_chunk.decode() except UnicodeDecodeError: diff --git a/tests/lib/testing_classes.py b/tests/lib/testing_classes.py index 6cd3c10d3e..1832efb7ed 100644 --- a/tests/lib/testing_classes.py +++ b/tests/lib/testing_classes.py @@ -260,4 +260,4 @@ class PublishTest(ModuleUnitTest): f != expected_dir_base and os.path.exists(f)) not_matched = expected.difference(published) - assert not not_matched, "Missing {} files".format(not_matched) \ No newline at end of file + assert not not_matched, "Missing {} files".format(not_matched) diff --git a/tests/unit/openpype/modules/sync_server/test_site_operations.py b/tests/unit/openpype/modules/sync_server/test_site_operations.py index ab15025399..6a861100a4 100644 --- a/tests/unit/openpype/modules/sync_server/test_site_operations.py +++ b/tests/unit/openpype/modules/sync_server/test_site_operations.py @@ -21,6 +21,9 @@ class TestSiteOperation(ModuleUnitTest): REPRESENTATION_ID = "60e578d0c987036c6a7b741d" + TEST_FILES = [("1eCwPljuJeOI8A3aisfOIBKKjcmIycTEt", + "test_site_operations.zip", '')] + @pytest.fixture(scope="module") def setup_sync_server_module(self, dbcon): """Get sync_server_module from ModulesManager""" @@ -109,7 +112,7 @@ class TestSiteOperation(ModuleUnitTest): site_names = [site["name"] for site in ret["files"][0]["sites"]] assert 'test_site' not in site_names, "Site name wasn't removed" - + @pytest.mark.usefixtures("setup_sync_server_module") def test_remove_site_again(self, dbcon, setup_sync_server_module): """Depends on test_add_site, must trow exception"""