Skip to main content
Help us improve PyPI by participating in user testing. All experience levels needed!

Pytest plugin for AWS integration tests

Project description

pytest-localstack

PyPI Travis-CI Codecov

pytest-localstack is a plugin for pytest to create AWS integration tests via a Localstack Docker container.

Read The Docs

Requires:

  • pytest >= 3.3.0
  • Docker

Features

  • Create pytest fixtures that start and stop a Localstack container.
  • Temporarily patch botocore to redirect botocore/boto3 API calls to Localstack container.
  • Plugin system to easily extend supports to other AWS client libraries such as aiobotocore.

Example

import boto3
import pytest_localstack

localstack = pytest_localstack.patch_fixture(
    services=["s3"],  # Limit to the AWS services you need.
    scope='module',  # Use the same Localstack container for all tests in this module.
    autouse=True,  # Automatically use this fixture in tests.
)

def test_s3_bucket_creation():
    s3 = boto3.resource('s3')  # Botocore/boto3 will be patched to use Localstack
    assert len(list(s3.buckets.all())) == 0
    bucket = s3.Bucket('foobar')
    bucket.create()
    assert len(list(s3.buckets.all())) == 1

Installation

Install with pipenv:

$ pipenv install pytest-localstack

(You have pipenv, right?)

TODO

  • More detailed docs.
  • Break Docker container running out of LocalstackSession.
  • Make botocore patching more comprehensible.
  • Add common test resource fixture factories i.e. S3 buckets, SQS queues, SNS topics, etc.
  • Test this works for non-localhost Docker containers.
  • Add other client libraries such as aiobotocore.

Change Log

0.1.0 (2018-03-13)

  • Initial release

Project details


Release history Release notifications

History Node

0.1.1.post1

History Node

0.1.1

This version
History Node

0.1.0

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
pytest_localstack-0.1.0-py2.py3-none-any.whl (37.2 kB) Copy SHA256 hash SHA256 Wheel py2.py3 Mar 14, 2018
pytest-localstack-0.1.0.tar.gz (1.3 MB) Copy SHA256 hash SHA256 Source None Mar 14, 2018

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page