File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed
Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change 77
88import context
99
10+
1011cur_dir = op .dirname (op .abspath (__file__ ))
1112
13+
14+ # Mock only once globally, before anything imports `log.py`
1215mock_msp = MagicMock (return_value = op .sep .join ([cur_dir , "data/mock_log" ]))
1316mock_bundle_paths = MagicMock ()
1417mock_bundle_paths .make_splunkhome_path = mock_msp
1518
19+ sys .modules ["splunk" ] = MagicMock ()
20+ sys .modules ["splunk.clilib" ] = MagicMock ()
1621sys .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" )
2032def setup_env ():
2133 # path manipulation get the 'splunk' library for the imports while running on GH Actions
You can’t perform that action at this time.
0 commit comments