diff --git a/frigate/test/http_api/test_http_config_go2rtc_streams.py b/frigate/test/http_api/test_http_config_go2rtc_streams.py index 7861488046..823bd8e460 100644 --- a/frigate/test/http_api/test_http_config_go2rtc_streams.py +++ b/frigate/test/http_api/test_http_config_go2rtc_streams.py @@ -56,6 +56,9 @@ class TestConfigGo2rtcStreamRestrictions(BaseTestHttp): find_patch.start() self.addCleanup(find_patch.stop) + env_patch = patch.dict(os.environ) + env_patch.start() + self.addCleanup(env_patch.stop) os.environ.pop("GO2RTC_ALLOW_ARBITRARY_EXEC", None) def _read_config(self) -> str: diff --git a/frigate/test/test_env.py b/frigate/test/test_env.py index d91e18c0ca..a3cf350ac7 100644 --- a/frigate/test/test_env.py +++ b/frigate/test/test_env.py @@ -232,6 +232,9 @@ class TestEnvVars(unittest.TestCase): """The go2rtc exec override cannot be enabled from the config.""" from frigate.util.services import is_go2rtc_arbitrary_exec_allowed + env_patch = patch.dict(os.environ) + env_patch.start() + self.addCleanup(env_patch.stop) os.environ.pop("GO2RTC_ALLOW_ARBITRARY_EXEC", None) ctx = self._make_context(install=True) with patch("frigate.util.services.os.path.isfile", return_value=False): @@ -243,10 +246,10 @@ class TestEnvVars(unittest.TestCase): def test_install_keeps_container_go2rtc_exec_override(self): """An override set in the container environment is left untouched.""" - os.environ["GO2RTC_ALLOW_ARBITRARY_EXEC"] = "true" ctx = self._make_context(install=True) - validate_env_vars({"GO2RTC_ALLOW_ARBITRARY_EXEC": "false"}, ctx) - self.assertEqual(os.environ.get("GO2RTC_ALLOW_ARBITRARY_EXEC"), "true") + with patch.dict(os.environ, {"GO2RTC_ALLOW_ARBITRARY_EXEC": "true"}): + validate_env_vars({"GO2RTC_ALLOW_ARBITRARY_EXEC": "false"}, ctx) + self.assertEqual(os.environ.get("GO2RTC_ALLOW_ARBITRARY_EXEC"), "true") if __name__ == "__main__":