diff --git a/addons/payment/tests/http_common.py b/addons/payment/tests/http_common.py index 8d277bb03d5..f9c60caf001 100644 --- a/addons/payment/tests/http_common.py +++ b/addons/payment/tests/http_common.py @@ -11,7 +11,7 @@ from odoo.tests import HttpCase from odoo.addons.payment.tests.utils import PaymentTestUtils -class PaymentHttpCommon(HttpCase, PaymentTestUtils): +class PaymentHttpCommon(PaymentTestUtils, HttpCase): """ HttpCase common to build and simulate requests going through payment controllers. Only use if you effectively want to test controllers. diff --git a/odoo/tests/common.py b/odoo/tests/common.py index bbe6f58909a..c0040c37000 100644 --- a/odoo/tests/common.py +++ b/odoo/tests/common.py @@ -1365,6 +1365,14 @@ class HttpCase(TransactionCase): cls = type(self) cls._logger = logging.getLogger('%s.%s' % (cls.__module__, cls.__name__)) + @classmethod + def setUpClass(cls): + super().setUpClass() + + ICP = cls.env['ir.config_parameter'] + ICP.set_param('web.base.url', cls.base_url()) + ICP.flush() + def setUp(self): super().setUp() if self.registry_test_mode: @@ -1482,16 +1490,8 @@ class HttpCase(TransactionCase): try: self.authenticate(login, login) - base_url = "http://%s:%s" % (HOST, odoo.tools.config['http_port']) - ICP = self.env['ir.config_parameter'] - ICP.set_param('web.base.url', base_url) - # flush updates to the database before launching the client side, - # otherwise they simply won't be visible - ICP.flush() - if re.match('[a-z]*:', url_path or ''): # about:, http:, ... - url = url_path - else: - url = "%s%s" % (base_url, url_path or '/') + self.env['base'].flush() + url = werkzeug.urls.url_join(self.base_url(), url_path) self._logger.info('Open "%s" in browser', url) if self.browser.screencasts_dir: @@ -1523,6 +1523,10 @@ class HttpCase(TransactionCase): self.browser.clear() self._wait_remaining_requests() + @classmethod + def base_url(cls): + return "http://%s:%s" % (HOST, odoo.tools.config['http_port']) + def start_tour(self, url_path, tour_name, step_delay=None, **kwargs): """Wrapper for `browser_js` to start the given `tour_name` with the optional delay between steps `step_delay`. Other arguments from