Skip to content

Commit 8a38040

Browse files
committed
tests: disable boto3 session caching to fix moto issues
If instances of clients are created outside of the moto patching, they will be cached by boto3 and return in subsequent runs, breaking some tests. While the best fix would be to avoid that situation, disabling the caching altogether is easier and ensures the issue won't return.
1 parent 126b626 commit 8a38040

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

stacker/tests/conftest.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22

33
import logging
44
import os
5+
import mock
56

67
import pytest
8+
from boto3 import Session
79

810

911
logger = logging.getLogger(__name__)
@@ -35,3 +37,13 @@ def aws_credentials():
3537
os.environ[key] = value
3638

3739
saved_env.clear()
40+
41+
42+
@pytest.fixture(scope='session', autouse=True)
43+
def boto3_disable_session_caching():
44+
def get_session(**kwargs):
45+
return Session(**kwargs)
46+
47+
with mock.patch('boto3._get_default_session',
48+
side_effect=get_session):
49+
yield

0 commit comments

Comments
 (0)