Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit ed6f3f2

Browse files
committedSep 19, 2024·
Always call progress.quit in mocked installing packages in tests
1 parent 5720502 commit ed6f3f2

File tree

1 file changed

+22
-20
lines changed

1 file changed

+22
-20
lines changed
 

‎tests/unit_tests/pyanaconda_tests/modules/payloads/payload/test_module_payload_dnf5_manager.py

+22-20
Original file line numberDiff line numberDiff line change
@@ -512,26 +512,28 @@ def _get_transaction_item(self, name, action=libdnf5.transaction.TransactionItem
512512

513513
def _install_packages(self, base, transaction, progress):
514514
"""Simulate the installation of packages."""
515-
transaction_items = list(map(self._get_transaction_item, ["p1", "p2", "p3"]))
516-
ts_total = len(transaction_items)
517-
for ts_done, item in enumerate(transaction_items):
518-
progress.install_start(item, ts_total)
519-
progress.install_progress(item, ts_done, ts_total)
520-
progress.script_start(
521-
item,
522-
item.nevra,
523-
libdnf5.rpm.TransactionCallbacks.ScriptType_PRE_INSTALL
524-
)
525-
progress.install_progress(item, ts_done + 1, ts_total)
526-
527-
for ts_done, item in enumerate(transaction_items):
528-
progress.script_start(
529-
item,
530-
item.nevra,
531-
libdnf5.rpm.TransactionCallbacks.ScriptType_POST_TRANSACTION
532-
)
533-
534-
progress.quit("DNF quit")
515+
try:
516+
transaction_items = list(map(self._get_transaction_item, ["p1", "p2", "p3"]))
517+
ts_total = len(transaction_items)
518+
for ts_done, item in enumerate(transaction_items):
519+
progress.install_start(item, ts_total)
520+
progress.install_progress(item, ts_done, ts_total)
521+
progress.script_start(
522+
item,
523+
item.nevra,
524+
libdnf5.rpm.TransactionCallbacks.ScriptType_PRE_INSTALL
525+
)
526+
progress.install_progress(item, ts_done + 1, ts_total)
527+
528+
for ts_done, item in enumerate(transaction_items):
529+
progress.script_start(
530+
item,
531+
item.nevra,
532+
libdnf5.rpm.TransactionCallbacks.ScriptType_POST_TRANSACTION
533+
)
534+
finally:
535+
# The quit must be called even if there is an error, otherwise the process never quits.
536+
progress.quit("DNF quit")
535537

536538
@patch.object(DNFManager, '_run_transaction')
537539
def test_install_packages_failed(self, run_transaction):

0 commit comments

Comments
 (0)
Please sign in to comment.