Skip to content

Commit e93e3e5

Browse files
committed
tests: fix platform detection for github actions
1 parent 6aa1c63 commit e93e3e5

1 file changed

Lines changed: 6 additions & 8 deletions

File tree

conftest.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import builtins
22
import os
3+
import platform
34
import re
45
import unittest.mock
56

@@ -12,14 +13,11 @@ def dyld_find_mock(lib_filename):
1213
_BUILTIN_IMPORT = builtins.__import__
1314

1415
def import_mock(name, *args, **kwargs):
15-
try:
16-
return _BUILTIN_IMPORT(name, *args, **kwargs)
17-
except ModuleNotFoundError as exc:
18-
if name == 'ctypes.macholib.dyld': # only available on mac
19-
dyld_module = unittest.mock.MagicMock()
20-
dyld_module.dyld_find = dyld_find_mock
21-
return dyld_module
22-
raise exc
16+
if name == 'ctypes.macholib.dyld' and platform.system() != 'Darwin':
17+
dyld_module = unittest.mock.MagicMock()
18+
dyld_module.dyld_find = dyld_find_mock
19+
return dyld_module
20+
return _BUILTIN_IMPORT(name, *args, **kwargs)
2321

2422
# required for tests/dlinfo_macosx_mock_test.py and doctests in dlinfo/_macosx.py.
2523
# @pytest.fixture(autouse=True) does not run before import statements.

0 commit comments

Comments
 (0)