{"id":20773008,"url":"https://github.com/whisller/pytest-serverless","last_synced_at":"2026-03-06T08:03:14.070Z","repository":{"id":34898899,"uuid":"187645724","full_name":"whisller/pytest-serverless","owner":"whisller","description":"Automatically mocks resources from serverless.yml in pytest using moto.","archived":false,"fork":false,"pushed_at":"2022-06-27T18:48:11.000Z","size":135,"stargazers_count":27,"open_issues_count":0,"forks_count":12,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-25T03:29:33.270Z","etag":null,"topics":["boto3","moto","pytest","serverless"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/whisller.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-05-20T13:27:12.000Z","updated_at":"2023-11-08T05:33:10.000Z","dependencies_parsed_at":"2022-08-08T18:00:09.021Z","dependency_job_id":null,"html_url":"https://github.com/whisller/pytest-serverless","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/whisller/pytest-serverless","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whisller%2Fpytest-serverless","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whisller%2Fpytest-serverless/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whisller%2Fpytest-serverless/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whisller%2Fpytest-serverless/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/whisller","download_url":"https://codeload.github.com/whisller/pytest-serverless/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whisller%2Fpytest-serverless/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30166877,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-06T07:56:45.623Z","status":"ssl_error","status_checked_at":"2026-03-06T07:55:55.621Z","response_time":250,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["boto3","moto","pytest","serverless"],"created_at":"2024-11-17T12:23:54.638Z","updated_at":"2026-03-06T08:03:14.033Z","avatar_url":"https://github.com/whisller.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"pytest-serverless\n---\nAutomatically mocks resources defined in serverless.yml file using [moto](https://github.com/spulec/moto) and uses them in [pytest](https://github.com/pytest-dev/pytest).\n\nThis way you can focus on writing tests rather than defining enormous list of fixtures.\n\n| master | PyPI | Python | pytest | Licence |\n| --- | --- | --- | --- | --- |\n| ![Master](https://github.com/whisller/pytest-serverless/workflows/Master/badge.svg) | [![PyPI](https://img.shields.io/pypi/v/pytest-serverless.svg)](https://pypi.org/project/pytest-serverless/) | ![](https://img.shields.io/pypi/pyversions/pytest-serverless.svg) | `6.2` | ![](https://img.shields.io/pypi/l/pytest-serverless.svg) |\n\n## Pre installation requirements\n- `serverless` installed\n- `pytest` installed\n\n## Installation\n```sh\npip install pytest-serverless\n```\n\n## Usage\nAssuming your `serverless.yml` file looks like:\n```yaml\nservice: my-microservice\nresources:\n Resources:\n   TableA:\n     Type: 'AWS::DynamoDB::Table'\n     DeletionPolicy: Delete\n     Properties:\n       TableName: ${self:service}.my-table\n       AttributeDefinitions:\n         - AttributeName: id\n           AttributeType: S\n         - AttributeName: company_id\n           AttributeType: S\n       KeySchema:\n         - AttributeName: id\n           KeyType: HASH\n       GlobalSecondaryIndexes:\n         - IndexName: company_id\n           KeySchema:\n             - AttributeName: company_id\n               KeyType: HASH\n           Projection:\n             ProjectionType: ALL\n           ProvisionedThroughput:\n             ReadCapacityUnits: 10\n             WriteCapacityUnits: 30\n       ProvisionedThroughput:\n         ReadCapacityUnits: 10\n         WriteCapacityUnits: 30\n```\n\nJust mark your test with `@pytest.mark.usefixtures(\"serverless\")` and `pytest-serverless` will automatically create `my-microservice.my-table` dynamodb table.\n```python\nimport boto3\nimport pytest\n\n\n@pytest.mark.usefixtures(\"serverless\")\ndef test():\n    table = boto3.resource(\"dynamodb\").Table(\"my-microservice.my-table\")\n    count_of_items = len(table.scan()[\"Items\"])\n    assert count_of_items == 0\n```\n\nYou can use a custom serverless file path setting the envionmnet variable `SERVERLESS_FILE_PATH`.\n\n```shell\n$ export SERVERLESS_FILE_PATH=/path/to/serverless.yml\n```\n\nYou can use choose both `sls` or `serverless` command to run, settings the environment variable `SERVERLESS_COMMAND`. It will only accpets `sls` or `serverless` values.\n\n```shell\n$ export SERVERLESS_COMMAND=sls\n```\n\n## Supported resources\n### AWS::DynamoDB::Table\n### AWS::SQS::Queue\n### AWS::SNS::Topic\n### AWS::S3::Bucket\n### AWS::KMS::Key\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwhisller%2Fpytest-serverless","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwhisller%2Fpytest-serverless","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwhisller%2Fpytest-serverless/lists"}