Integration tests

    LocalStack has an extensive set of integration tests. This document describes how to run and write integration tests.

    To run the tests you can use the make target and set the variable.

    or run it manually within the virtual environment:

    1. python -m pytest --log-cli-level=INFO tests/integration

    You can further specify the file and test class you want to run in the test path:

    Test against a running LocalStack instance

    It can be useful to run an integration test against the real AWS cloud using your credentials. You can do this by setting the environment variable TEST_TARGET="AWS_CLOUD".

    Writing a test

    We use for our testing framework. Older tests were written using the unittest framework, but its use is discouraged.

    If your test matches the pattern tests/integration/**/test_*.py it will be picked up by the integration test suite.

    Functional-style tests

    You can write functional style tests by defining a function with the prefix with basic asserts:

    1. def test_something():
    2. assert True is not False

    Fixtures

    We use the pytest fixture concept, and provide several fixtures you can use when writing AWS tests. For example, to inject a Boto client for SQS, you can specify the sqs_client in your test method:

    1. assert len(sqs_client.list_queues()["QueueUrls"]) == 0

    We also provide fixtures for certain disposable resources, like buckets:

    Another pattern we use is the factory as fixture pattern.

    1. def test_something_on_multiple_buckets(s3_create_bucket):
    2. bucket1 = s3_create_bucket()
    3. bucket2 = s3_create_bucket()

    You can find the list of available fixtures in the .