Skip to content
Get Started for Free
To improve reliability, we’ve moved to a single, authenticated LocalStack for AWS image that requires an auth token. For more details on plans and pricing, see our pricing page.

Testing Utils

LocalStack provides a set of tools to simplify application testing on LocalStack. These tools are available for Python and can be used to integrate with various unit testing frameworks and simplify the setup of AWS clients with LocalStack.

This Python Testing Utils streamlines the integration of Localstack with your unit tests.

Terminal window
pip install localstack-utils
import time
import boto3
import unittest
from localstack_utils.localstack import startup_localstack, stop_localstack
class TestKinesis(unittest.TestCase):
def setUp(self):
startup_localstack()
def tearDown(self):
stop_localstack()
return super().tearDown()
def test_create_stream(self):
kinesis = boto3.client(
service_name="kinesis",
aws_access_key_id="test",
aws_secret_access_key="test",
endpoint_url="http://localhost.localstack.cloud:4566",
)
kinesis.create_stream(StreamName="test", ShardCount=1)
time.sleep(1)
response = kinesis.list_streams()
self.assertGreater(len(response.get("StreamNames", [])), 0)
Was this page helpful?