mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 21:04:40 +01:00
OP-3426 - fix check for failed test
If fixture fails before test is finished, there is no `rep_call` method, this way it should be more safe.
This commit is contained in:
parent
2dfb34bfae
commit
a20c102b85
2 changed files with 21 additions and 2 deletions
|
|
@ -43,3 +43,15 @@ def app_variant(request):
|
|||
@pytest.fixture(scope="module")
|
||||
def timeout(request):
|
||||
return request.config.getoption("--timeout")
|
||||
|
||||
|
||||
@pytest.hookimpl(tryfirst=True, hookwrapper=True)
|
||||
def pytest_runtest_makereport(item, call):
|
||||
# execute all other hooks to obtain the report object
|
||||
outcome = yield
|
||||
rep = outcome.get_result()
|
||||
|
||||
# set a report attribute for each phase of a call, which can
|
||||
# be "setup", "call", "teardown"
|
||||
|
||||
setattr(item, "rep_" + rep.when, rep)
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ class ModuleUnitTest(BaseTest):
|
|||
yield tmpdir
|
||||
|
||||
persist = (persist or self.PERSIST or
|
||||
request.node.rep_call.failed)
|
||||
self.is_test_failed(request))
|
||||
if not persist:
|
||||
print("Removing {}".format(tmpdir))
|
||||
shutil.rmtree(tmpdir)
|
||||
|
|
@ -146,7 +146,7 @@ class ModuleUnitTest(BaseTest):
|
|||
|
||||
yield db_handler
|
||||
|
||||
persist = self.PERSIST or request.node.rep_call.failed
|
||||
persist = self.PERSIST or self.is_test_failed(request)
|
||||
if not persist:
|
||||
db_handler.teardown(self.TEST_DB_NAME)
|
||||
db_handler.teardown(self.TEST_OPENPYPE_NAME)
|
||||
|
|
@ -172,6 +172,13 @@ class ModuleUnitTest(BaseTest):
|
|||
mongo_client = OpenPypeMongoConnection.get_mongo_client()
|
||||
yield mongo_client[self.TEST_OPENPYPE_NAME]["settings"]
|
||||
|
||||
def is_test_failed(self, request):
|
||||
# if request.node doesn't have rep_call, something failed
|
||||
try:
|
||||
return request.node.rep_call.failed
|
||||
except AttributeError:
|
||||
return True
|
||||
|
||||
|
||||
class PublishTest(ModuleUnitTest):
|
||||
"""Test class for publishing in hosts.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue