Created
November 24, 2020 21:28
-
-
Save mneil/584c151c3ae239c565513f0a87c40c2b to your computer and use it in GitHub Desktop.
Revisions
-
mneil created this gist
Nov 24, 2020 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,25 @@ ''' Unit test setup automatically called ''' from unittest import mock import pytest # Fixture, autouse @pytest.fixture(scope='session', autouse=True) def patch_boto3(request): '''patch things for every unit test''' # Patch boto client to return a magic mock by default during # Avoids ever making real calls in tests or getting botocore # credentials errors in tests patched = mock.patch('botocore.client.BaseClient._make_api_call') # Start the patch patched.start() def unpatch(): '''try to unpatch if the patch is still active''' try: patched.stop() except IndexError: pass # When the test is over, run this method request.addfinalizer(unpatch)