Skip to content

Instantly share code, notes, and snippets.

@GeneralTesler
Created May 29, 2019 01:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GeneralTesler/a84880334ba13b7c2147e83d47cb391a to your computer and use it in GitHub Desktop.
Save GeneralTesler/a84880334ba13b7c2147e83d47cb391a to your computer and use it in GitHub Desktop.
Python3 - mocking AWS services for unittest-ing using moto
from moto import mock_<service>
import boto3
import unittest
class TestFooBar(unittest.TestCase):
def __init__(self, *args, **kwargs):
super(TestFooBar, self).__init__(*args, **kwargs)
self.client = boto3.client("<service>")
self.mock = mock_<service>()
def setUp(self):
self.mock.start(reset=True)
# ...
def tearDown(self):
self.mock.stop()
# ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment