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.10.

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.8.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.8.0-py3-none-any.whl (23.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pytest_localstack-0.8.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.8.0.tar.gz
Algorithm Hash digest
SHA256 7f1104d310b8e0c4f8d8ce203022c9a0190063abee9d606a1b329bb9e7a5a2f7
MD5 946f66dd2ca16aa3e20f3bcc14a8df91
BLAKE2b-256 a21850329fdae543af4c8edf6046e3de1528ca4bf4f3fdee3711d52ad140b687

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytest_localstack-0.8.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.8.0-py3-none-any.whl.

File metadata

File hashes

Hashes for pytest_localstack-0.8.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3226778a6d258d433b99346ec87398979d7855da74567c2fcbaa0a5f9810f969
MD5 ebc1730d8adb5a847e7e2e4620538d9b
BLAKE2b-256 40f3a619a6cc61801618060d5df3d982d8a39afeefbd12558d9a40becb8b4dd8

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytest_localstack-0.8.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

This release

0.8.0 This release

2 files

0.7.0

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