I'm trying to mock an s3 instance with Moto
, which does seem to work, however for some reason it seems to search the real s3 for files instead of the mocked s3.
My working hierarchy looks something like this:
root
--tests
----mock s3
------__init__.py
------conftest.py
------test mock s3.py
In conftest
I'm mocking s3 like this:
fixture
def mock s3():
mock = mock_s3()
mock.start()
client = boto3.client('s3')
add buckets and keys to the client
yield client
mock.stop()
And test mock s3.py
looks like this:
usefixtures('mock s3')
def test_something():
path = Path('s3://bucket/key')
files = all the files from the path
assert some stuff
And when I run pytest tests/mock s3/test mock s3.py
it seems to work fine. However if I don't call the file directly when I run pytest
(for example pytest tests/mock s3
) for some reason it doesn't seem to use my mocked s3, files
gets back the real files from s3.
The mock fixture still gets applied (I know because I added prints which got printed) but for some reason it can't find the files in the mock.
EDIT -- added path and files to test_something