diff --git a/tests/unit_tests/pyanaconda_tests/modules/payloads/payload/test_module_payload_dnf5_manager.py b/tests/unit_tests/pyanaconda_tests/modules/payloads/payload/test_module_payload_dnf5_manager.py index 47833db6fb1..a989edbf5e1 100644 --- a/tests/unit_tests/pyanaconda_tests/modules/payloads/payload/test_module_payload_dnf5_manager.py +++ b/tests/unit_tests/pyanaconda_tests/modules/payloads/payload/test_module_payload_dnf5_manager.py @@ -512,26 +512,28 @@ def _get_transaction_item(self, name, action=libdnf5.transaction.TransactionItem def _install_packages(self, base, transaction, progress): """Simulate the installation of packages.""" - transaction_items = list(map(self._get_transaction_item, ["p1", "p2", "p3"])) - ts_total = len(transaction_items) - for ts_done, item in enumerate(transaction_items): - progress.install_start(item, ts_total) - progress.install_progress(item, ts_done, ts_total) - progress.script_start( - item, - item.nevra, - libdnf5.rpm.TransactionCallbacks.ScriptType_PRE_INSTALL - ) - progress.install_progress(item, ts_done + 1, ts_total) - - for ts_done, item in enumerate(transaction_items): - progress.script_start( - item, - item.nevra, - libdnf5.rpm.TransactionCallbacks.ScriptType_POST_TRANSACTION - ) - - progress.quit("DNF quit") + try: + transaction_items = list(map(self._get_transaction_item, ["p1", "p2", "p3"])) + ts_total = len(transaction_items) + for ts_done, item in enumerate(transaction_items): + progress.install_start(item, ts_total) + progress.install_progress(item, ts_done, ts_total) + progress.script_start( + item, + item.nevra, + libdnf5.rpm.TransactionCallbacks.ScriptType_PRE_INSTALL + ) + progress.install_progress(item, ts_done + 1, ts_total) + + for ts_done, item in enumerate(transaction_items): + progress.script_start( + item, + item.nevra, + libdnf5.rpm.TransactionCallbacks.ScriptType_POST_TRANSACTION + ) + finally: + # The quit must be called even if there is an error, otherwise the process never quits. + progress.quit("DNF quit") @patch.object(DNFManager, '_run_transaction') def test_install_packages_failed(self, run_transaction):