Skip to main content
PyPI Travis-CI Codecov https://img.shields.io/github/license/mintel/pytest-localstack.svg https://img.shields.io/github/issues/mintel/pytest-localstack.svg https://img.shields.io/github/forks/mintel/pytest-localstack.svg https://img.shields.io/github/stars/mintel/pytest-localstack.svg

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

Read The Docs

Requires:

  • pytest >= 7

  • Docker

Tested against Python >= 3.9.

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

Services

  • apigateway

  • cloudformation

  • cloudwatch

  • dynamodb

  • dynamodbstreams

  • ec2

  • es

  • firehose

  • iam

  • kinesis

  • lambda

  • logs

  • redshift

  • route53

  • s3

  • secretsmanager

  • ses

  • sns

  • sqs

  • ssm

  • stepfunctions

  • sts

Installation

$ pip install pytest-localstack

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.

Download files

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

Source Distribution

pytest_localstack-0.7.0.tar.gz (19.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pytest_localstack-0.7.0-py3-none-any.whl (23.7 kB view details)

Uploaded Python 3

File details

Details for the file pytest_localstack-0.7.0.tar.gz.

File metadata

  • Download URL: pytest_localstack-0.7.0.tar.gz
  • Upload date:
  • Size: 19.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for pytest_localstack-0.7.0.tar.gz
Algorithm Hash digest
SHA256 6926d1587bf05d3e889f8989b299d11bf7f93ce6678f9d13918c4f4c64ffb057
MD5 487291257ce4b09146be148d141b73a9
BLAKE2b-256 1b8ed813e221ba39da21b909ec61164864d1f96b2a49c644fcb246afcbca5287

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytest_localstack-0.7.0.tar.gz:

Publisher: release.yml on mintel/pytest-localstack

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pytest_localstack-0.7.0-py3-none-any.whl.

File metadata

File hashes

Hashes for pytest_localstack-0.7.0-py3-none-any.whl
Algorithm Hash digest
SHA256 828b9ee08b717c672bc45e363baf7ccb535344760167102dd3a19770bd21683b
MD5 2b9d6ffa0ce30b994c318eb280997cfc
BLAKE2b-256 c41f26651ca796e568f2af446ea9ac0cab2cc3fb867c4986f90b507ecc9530eb

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytest_localstack-0.7.0-py3-none-any.whl:

Publisher: release.yml on mintel/pytest-localstack

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.8.0

2 files

This release

0.7.0 This release

2 files

0.6.1

2 files

0.6.0

2 files

0.5.0

2 files

0.4.1

2 files

0.4.0

2 files

0.3.2

2 files

0.3.1

2 files

0.3.0

2 files

0.2.0

2 files

0.1.5

2 files

0.1.4

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1.post1

2 files

0.1.1

1 file

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page