Use patch.dict in deprecation test "test_check_if_deprecated_constant" (#106117)

This commit is contained in:
Robert Resch 2023-12-20 16:06:26 +01:00 committed by GitHub
parent 56967a92e0
commit 5a3db078d5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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(