Skip to content

Commit bee7116

Browse files
committed
removed side effect in tests
1 parent 97a271a commit bee7116

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

tests/unit/test_resources.py

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import mock
22
import dash
33
from dash import dcc, html # noqa: F401
4-
import sys
54

65
from dash.development.base_component import ComponentRegistry
76

@@ -112,15 +111,14 @@ def test_collect_and_register_resources(mocker):
112111
)
113112
with mock.patch("dash.dash.os.stat", return_value=StatMock()):
114113
with mock.patch("dash.dash.importlib.import_module") as import_mock:
115-
sys.modules["dash_html_components"] = dcc
116-
117-
import_mock.return_value = dcc
118-
app._collect_and_register_resources(
119-
[
120-
{
121-
"namespace": "dash_html_components",
122-
"relative_package_path": "dash_html_components.min.js",
123-
},
124-
]
125-
)
126-
import_mock.assert_any_call("dash_html_components")
114+
with mock.patch("sys.modules", {"dash_html_components": dcc}):
115+
import_mock.return_value = dcc
116+
app._collect_and_register_resources(
117+
[
118+
{
119+
"namespace": "dash_html_components",
120+
"relative_package_path": "dash_html_components.min.js",
121+
},
122+
]
123+
)
124+
import_mock.assert_any_call("dash_html_components")

0 commit comments

Comments
 (0)