From 5a3db078d5880666141f2b8eecb2c8d1a2c0c641 Mon Sep 17 00:00:00 2001 From: Robert Resch Date: Wed, 20 Dec 2023 16:06:26 +0100 Subject: [PATCH] Use patch.dict in deprecation test "test_check_if_deprecated_constant" (#106117) --- tests/helpers/test_deprecation.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tests/helpers/test_deprecation.py b/tests/helpers/test_deprecation.py index 4ad1677a16f..6816c7701aa 100644 --- a/tests/helpers/test_deprecation.py +++ b/tests/helpers/test_deprecation.py @@ -293,10 +293,8 @@ def test_check_if_deprecated_constant( } filename = f"/home/paulus/{module_name.replace('.', '/')}.py" - # mock module for homeassistant/helpers/frame.py#get_integration_frame - sys.modules[module_name] = Mock(__file__=filename) - - with patch( + # mock sys.modules for homeassistant/helpers/frame.py#get_integration_frame + with patch.dict(sys.modules, {module_name: Mock(__file__=filename)}), patch( "homeassistant.helpers.frame.extract_stack", return_value=[ Mock(