Completely mock Torch on macos

we already skip tests - now we also need to skip it's imports.
This commit is contained in:
Matthias
2023-12-07 07:25:34 +01:00
parent d3d9f3281e
commit d123d3bb82

View File

@@ -22,7 +22,17 @@ def is_mac() -> bool:
@pytest.fixture(autouse=True)
def patch_torch_initlogs(mocker) -> None:
mocker.patch("torch._logging._init_logs")
if is_mac():
# Mock torch import completely
import sys
import types
module_name = 'torch'
mocked_module = types.ModuleType(module_name)
sys.modules[module_name] = mocked_module
else:
mocker.patch("torch._logging._init_logs")
@pytest.fixture(scope="function")