From eefe887e9a1d4862f743f49d36678cbd26b5453d Mon Sep 17 00:00:00 2001 From: Mahesh Shetty Date: Thu, 12 Dec 2024 16:56:07 +0530 Subject: [PATCH] Making sure cnv deployment clean up occurs even when deployment fails in between Signed-off-by: Mahesh Shetty --- tests/conftest.py | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index 459eaa3f267..6c6317d1f15 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -8585,21 +8585,24 @@ def setup_cnv(request): """ cnv_obj = CNVInstaller() installed = False - if not cnv_obj.post_install_verification(): - installed = True - cnv_obj.deploy_cnv() + try: + if not cnv_obj.post_install_verification(): + installed = True + cnv_obj.deploy_cnv() - def finalizer(): - """ - Clean up CNV deployment + finally: - """ + def finalizer(): + """ + Clean up CNV deployment - # Uninstall CNV only if installed by this fixture - if installed: - cnv_obj.uninstall_cnv() + """ - request.addfinalizer(finalizer) + # Uninstall CNV only if installed by this fixture + if installed: + cnv_obj.uninstall_cnv() + + request.addfinalizer(finalizer) @pytest.fixture(scope="class")