From 2c1641f8639a01958d7daae8fabeee6dfa66c2a4 Mon Sep 17 00:00:00 2001 From: Simone Orsi Date: Tue, 20 Oct 2026 11:29:27 +0200 Subject: [PATCH] [FIX] endpoint_route_handler: scope registry mutation in tests The mocked request set `registry._init_modules` to an empty set and never restored it. The registry is shared, so every routing map built afterwards dropped the controllers of all modules: tests of other modules (eg: `http_json_dispatcher`) got 404 on their routes when run in the same process. Patch it only for the duration of the mocked request. --- endpoint_route_handler/tests/common.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/endpoint_route_handler/tests/common.py b/endpoint_route_handler/tests/common.py index 2ed24331..ede397c2 100644 --- a/endpoint_route_handler/tests/common.py +++ b/endpoint_route_handler/tests/common.py @@ -3,6 +3,7 @@ # License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). import contextlib +from unittest import mock from odoo.tests.common import TransactionCase, tagged from odoo.tools import DotDict @@ -49,5 +50,7 @@ def _get_mocked_request( for k, v in request_attrs.items(): setattr(mocked_request, k, v) mocked_request.make_response = lambda data, **kw: data - mocked_request.registry._init_modules = set() - yield mocked_request + # Scoped: the registry is shared, and emptying its `_init_modules` + # for good would drop the controllers of every module from the routing map + with mock.patch.object(mocked_request.registry, "_init_modules", set()): + yield mocked_request