diff --git a/addons/payment/tests/common.py b/addons/payment/tests/common.py index 9b9386010be..e298dca688b 100644 --- a/addons/payment/tests/common.py +++ b/addons/payment/tests/common.py @@ -228,3 +228,8 @@ class PaymentCommon(TransactionCase): self.fail(f"{func.__name__} should not raise error of class {exception_class.__name__}") except Exception: pass # Any exception whose class is not monitored is caught and ignored + + def _skip_if_account_payment_is_not_installed(self): + """ Skip current test if `account_payment` module is not installed. """ + if not self.account_payment_installed: + self.skipTest("account_payment module is not installed") diff --git a/addons/payment_asiapay/tests/test_payment_transaction.py b/addons/payment_asiapay/tests/test_payment_transaction.py index ccff3c62309..6abd076047e 100644 --- a/addons/payment_asiapay/tests/test_payment_transaction.py +++ b/addons/payment_asiapay/tests/test_payment_transaction.py @@ -25,6 +25,8 @@ class TestPaymentTransaction(AsiaPayCommon, PaymentHttpCommon): @freeze_time('2011-11-02 12:00:21') # Freeze time for consistent singularization behavior. def test_reference_is_computed_based_on_document_name(self): """ Test the computation of reference prefixes based on the provided invoice. """ + self._skip_if_account_payment_is_not_installed() + invoice = self.env['account.move'].create({}) reference = self.env['payment.transaction']._compute_reference( self.asiapay.code, invoice_ids=[Command.set([invoice.id])] diff --git a/addons/payment_ogone/tests/test_ogone.py b/addons/payment_ogone/tests/test_ogone.py index 85091fb092c..2c5b2700892 100644 --- a/addons/payment_ogone/tests/test_ogone.py +++ b/addons/payment_ogone/tests/test_ogone.py @@ -45,8 +45,7 @@ class OgoneTest(OgoneCommon, PaymentHttpCommon): @freeze_time('2011-11-02 12:00:21') # Freeze time for consistent singularization behavior def test_reference_is_computed_based_on_document_name(self): """ Test computation of reference prefixes based on the provided invoice. """ - if not self.env['ir.module.module']._get('account').state == 'installed': - self.skipTest('account module not installed') + self._skip_if_account_payment_is_not_installed() invoice = self.env['account.move'].create({}) reference = self.env['payment.transaction']._compute_reference( diff --git a/addons/payment_payulatam/tests/test_payulatam.py b/addons/payment_payulatam/tests/test_payulatam.py index 1acd7057a67..afc7be8ffcf 100644 --- a/addons/payment_payulatam/tests/test_payulatam.py +++ b/addons/payment_payulatam/tests/test_payulatam.py @@ -46,8 +46,7 @@ class PayULatamTest(PayULatamCommon, PaymentHttpCommon): @freeze_time('2011-11-02 12:00:21') # Freeze time for consistent singularization behavior def test_reference_is_computed_based_on_document_name(self): """ Test computation of reference prefixes based on the provided invoice. """ - if not self.env['ir.module.module']._get('account').state == 'installed': - self.skipTest('account module not installed') + self._skip_if_account_payment_is_not_installed() invoice = self.env['account.move'].create({}) reference = self.env['payment.transaction']._compute_reference(