When I run the following test alone, it passes. But when I run it with other tests, even if this test is the first to run it fails:
from runpy import run_path
from unittest.mock import patch, MagicMock
@patch('boto3.client', autospec=True)
def test_scripts(mock_boto3_client: MagicMock):
mock_boto3_client().head_object.return_value = {}
run_path(
'src/scripts/dynamic_script.py',
run_name='__main__'
)
This seems to somehow be affected by other mocks or imports, but it's unclear how they would affect this test when it runs first