Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -153,14 +153,14 @@ def mock_any_of(allowed_values: list) -> HookMetaService.MockEnum:
]:
try:
if not find_spec(mod_name):
raise ModuleNotFoundError
raise ModuleNotFoundError(f"No module named {mod_name!r}", name=mod_name)
except ModuleNotFoundError:
sys.modules[mod_name] = MagicMock()

# We conditionally inject mock classes for missing dependencies
# to ensure `ProvidersManager` can initialize hook connection widgets
# without crashing when FAB/WTForms are not installed.
if "wtforms.StringField" not in sys.modules:
if isinstance(sys.modules.get("wtforms"), MagicMock):
# Only apply mocks if the actual module wasn't loaded beforehand.
# This avoids thread-safety issues caused by `unittest.mock.patch` mutating global states.
with (
Expand Down