From fca02700e9688f8e22a3f2db8933024bcf6842f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Tue, 7 Jul 2026 19:16:08 +0200 Subject: [PATCH] Re-raise transaction error from sub-test of button Since a05fa06b3a4c the test of button is executed under the subTest context manager but if the method is raising a TransactionError, it is considered as a failure for the test. But we need this exception to be raised up to the with_transaction decorator in order to fix the transaction and execute fully the method of the button. --- trytond/trytond/tests/test_tryton.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/trytond/trytond/tests/test_tryton.py b/trytond/trytond/tests/test_tryton.py index 95edd90fb8..846d47795d 100644 --- a/trytond/trytond/tests/test_tryton.py +++ b/trytond/trytond/tests/test_tryton.py @@ -1173,6 +1173,7 @@ class ModuleTestCase(_DBTestCase): if not issubclass(model, ModelView): continue for button in model._buttons: + transaction_error = None with self.subTest(model=model.__name__, button=button): try: if is_instance_method(model, button): @@ -1181,6 +1182,11 @@ class ModuleTestCase(_DBTestCase): getattr(model, button)([]) except (UserError, UserWarning): pass + except TransactionError as e: + transaction_error = e + pass + if transaction_error: + raise transaction_error @with_transaction() def test_xml_files(self):