Skip to content

Commit 82d5d0a

Browse files
committed
test: add mock make_splunknhome_path to integration tests
1 parent 3f734a7 commit 82d5d0a

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

tests/integration/conftest.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,27 @@
77

88
import context
99

10+
1011
cur_dir = op.dirname(op.abspath(__file__))
1112

13+
14+
# Mock only once globally, before anything imports `log.py`
1215
mock_msp = MagicMock(return_value=op.sep.join([cur_dir, "data/mock_log"]))
1316
mock_bundle_paths = MagicMock()
1417
mock_bundle_paths.make_splunkhome_path = mock_msp
1518

19+
sys.modules["splunk"] = MagicMock()
20+
sys.modules["splunk.clilib"] = MagicMock()
1621
sys.modules["splunk.clilib.bundle_paths"] = mock_bundle_paths
1722

1823

24+
@pytest.fixture(autouse=True)
25+
def patch_log_msp(monkeypatch):
26+
"""Ensure log.msp is patched in all tests after mocking sys.modules."""
27+
from solnlib import log # only import after sys.modules is patched
28+
monkeypatch.setattr(log, "msp", mock_msp)
29+
30+
1931
@pytest.fixture(autouse=True, scope="session")
2032
def setup_env():
2133
# path manipulation get the 'splunk' library for the imports while running on GH Actions

0 commit comments

Comments
 (0)