diff --git a/server_environment/tests/common.py b/server_environment/tests/common.py index 43682a468..9c48a10a7 100644 --- a/server_environment/tests/common.py +++ b/server_environment/tests/common.py @@ -6,26 +6,14 @@ from unittest.mock import patch from odoo.tests import common -from odoo.tools.config import config import odoo.addons.server_environment.models.server_env_mixin as server_env_mixin from odoo.addons.server_environment import server_env class ServerEnvironmentCase(common.SavepointCase): - - _test_case_running_env = "testing" - def setUp(self): super().setUp() - self._original_running_env = config.get("running_env") - if self._test_case_running_env is not None: - config["running_env"] = self._test_case_running_env - server_env._load_running_env() - - def tearDown(self): - super().tearDown() - config["running_env"] = self._original_running_env @contextmanager def set_config_dir(self, path): diff --git a/server_environment/tests/test_environment_variable.py b/server_environment/tests/test_environment_variable.py index 8ea3b51fd..a33bf7a67 100644 --- a/server_environment/tests/test_environment_variable.py +++ b/server_environment/tests/test_environment_variable.py @@ -2,13 +2,16 @@ # License GPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from odoo.tools.config import config +from unittest.mock import patch + +from odoo.tools.config import config as odoo_config from odoo.addons.server_environment import server_env from .common import ServerEnvironmentCase +@patch.dict(odoo_config.options, {"running_env": "testing"}) class TestEnvironmentVariables(ServerEnvironmentCase): def test_env_variables(self): public = "[section]\n" "foo=bar\n" "bar=baz\n" @@ -29,9 +32,8 @@ def test_env_variables_override(self): self.assertEqual(val, "foo") +@patch.dict(odoo_config.options, {"running_env": ""}) class TestRunningEnv(ServerEnvironmentCase): - - _test_case_running_env = "" # empty -> no env set - def test_running_env_default(self): - self.assertEqual(config["running_env"], "test") + server_env._load_running_env() + self.assertEqual(odoo_config["running_env"], "test") diff --git a/server_environment/tests/test_server_environment.py b/server_environment/tests/test_server_environment.py index 48df0cdc5..d34c67663 100644 --- a/server_environment/tests/test_server_environment.py +++ b/server_environment/tests/test_server_environment.py @@ -1,9 +1,14 @@ # Copyright 2018 Camptocamp (https://www.camptocamp.com). # License GPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from unittest.mock import patch + +from odoo.tools.config import config as odoo_config + from .. import server_env from . import common +@patch.dict(odoo_config.options, {"running_env": "testing"}) class TestEnv(common.ServerEnvironmentCase): def test_view(self): model = self.env["server.config"]