mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 21:04:40 +01:00
OP-3426 - fix - failed class variable wasn't changed
Pytest classes cannot have __init__, so this ugly way is implemented for now to keep flag of failure to check before teardown. Marking all class variables didn't work for some reason.
This commit is contained in:
parent
d3769b3b73
commit
e5a604d58f
1 changed files with 11 additions and 13 deletions
|
|
@ -51,8 +51,6 @@ class ModuleUnitTest(BaseTest):
|
|||
|
||||
TEST_DATA_FOLDER = None
|
||||
|
||||
failed = False
|
||||
|
||||
@pytest.fixture(scope='session')
|
||||
def monkeypatch_session(self):
|
||||
"""Monkeypatch couldn't be used with module or session fixtures."""
|
||||
|
|
@ -83,7 +81,7 @@ class ModuleUnitTest(BaseTest):
|
|||
print("Temporary folder created:: {}".format(tmpdir))
|
||||
yield tmpdir
|
||||
|
||||
persist = persist or self.PERSIST or self.failed
|
||||
persist = persist or self.PERSIST or ModuleUnitTest.failed
|
||||
if not persist:
|
||||
print("Removing {}".format(tmpdir))
|
||||
shutil.rmtree(tmpdir)
|
||||
|
|
@ -146,7 +144,7 @@ class ModuleUnitTest(BaseTest):
|
|||
|
||||
yield db_handler
|
||||
|
||||
persist = self.PERSIST or self.failed
|
||||
persist = self.PERSIST or ModuleUnitTest.failed
|
||||
if not persist:
|
||||
db_handler.teardown(self.TEST_DB_NAME)
|
||||
db_handler.teardown(self.TEST_OPENPYPE_NAME)
|
||||
|
|
@ -308,7 +306,7 @@ class PublishTest(ModuleUnitTest):
|
|||
while launched_app.poll() is None:
|
||||
time.sleep(0.5)
|
||||
if time.time() - time_start > timeout:
|
||||
self.failed = True
|
||||
ModuleUnitTest.failed = True
|
||||
launched_app.terminate()
|
||||
raise ValueError("Timeout reached")
|
||||
|
||||
|
|
@ -347,7 +345,7 @@ class PublishTest(ModuleUnitTest):
|
|||
|
||||
not_matched = expected.symmetric_difference(filtered_published)
|
||||
if not_matched:
|
||||
self.failed = True
|
||||
ModuleUnitTest.failed = True
|
||||
raise AssertionError("Missing {} files".format(
|
||||
"\n".join(sorted(not_matched))))
|
||||
|
||||
|
|
@ -364,7 +362,7 @@ class DeadlinePublishTest(PublishTest):
|
|||
while launched_app.poll() is None:
|
||||
time.sleep(0.5)
|
||||
if time.time() - time_start > timeout:
|
||||
self.failed = True
|
||||
ModuleUnitTest.failed = True
|
||||
launched_app.terminate()
|
||||
raise ValueError("Timeout reached")
|
||||
|
||||
|
|
@ -373,11 +371,11 @@ class DeadlinePublishTest(PublishTest):
|
|||
"**/*_metadata.json"),
|
||||
recursive=True)
|
||||
if not metadata_json:
|
||||
self.failed = True
|
||||
ModuleUnitTest.failed = True
|
||||
raise RuntimeError("No metadata file found. No job id.")
|
||||
|
||||
if len(metadata_json) > 1:
|
||||
self.failed = True
|
||||
ModuleUnitTest.failed = True
|
||||
raise RuntimeError("Too many metadata files found.")
|
||||
|
||||
with open(metadata_json[0]) as fp:
|
||||
|
|
@ -390,7 +388,7 @@ class DeadlinePublishTest(PublishTest):
|
|||
deadline_url = deadline_module.deadline_urls["default"]
|
||||
|
||||
if not deadline_url:
|
||||
self.failed = True
|
||||
ModuleUnitTest.failed = True
|
||||
raise ValueError("Must have default deadline url.")
|
||||
|
||||
url = "{}/api/jobs?JobId={}".format(deadline_url, deadline_job_id)
|
||||
|
|
@ -400,17 +398,17 @@ class DeadlinePublishTest(PublishTest):
|
|||
while not valid_date_finished:
|
||||
time.sleep(0.5)
|
||||
if time.time() - time_start > timeout:
|
||||
self.failed = True
|
||||
ModuleUnitTest.failed = True
|
||||
raise ValueError("Timeout for DL finish reached")
|
||||
|
||||
response = requests.get(url, timeout=10)
|
||||
if not response.ok:
|
||||
self.failed = True
|
||||
ModuleUnitTest.failed = True
|
||||
msg = "Couldn't connect to {}".format(deadline_url)
|
||||
raise RuntimeError(msg)
|
||||
|
||||
if not response.json():
|
||||
self.failed = True
|
||||
ModuleUnitTest.failed = True
|
||||
raise ValueError("Couldn't find {}".format(deadline_job_id))
|
||||
|
||||
# '0001-...' returned until job is finished
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue