{"id":13468245,"url":"https://github.com/avast/pytest-docker","last_synced_at":"2026-04-08T14:32:33.627Z","repository":{"id":40248717,"uuid":"84156108","full_name":"avast/pytest-docker","owner":"avast","description":"Docker-based integration tests","archived":false,"fork":false,"pushed_at":"2025-11-12T13:42:28.000Z","size":110,"stargazers_count":485,"open_issues_count":22,"forks_count":76,"subscribers_count":8,"default_branch":"master","last_synced_at":"2026-02-11T01:56:53.848Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"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/avast.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2017-03-07T04:51:13.000Z","updated_at":"2026-02-08T15:50:31.000Z","dependencies_parsed_at":"2024-01-16T10:36:49.372Z","dependency_job_id":"19fb074e-2b59-49c6-a3d0-44c7122a2198","html_url":"https://github.com/avast/pytest-docker","commit_stats":{"total_commits":56,"total_committers":17,"mean_commits":"3.2941176470588234","dds":0.8035714285714286,"last_synced_commit":"519b155009b6f3570c01f1f56e7c4e6ce3c5c760"},"previous_names":["andrelouiscaron/pytest-docker"],"tags_count":34,"template":false,"template_full_name":null,"purl":"pkg:github/avast/pytest-docker","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/avast%2Fpytest-docker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/avast%2Fpytest-docker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/avast%2Fpytest-docker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/avast%2Fpytest-docker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/avast","download_url":"https://codeload.github.com/avast/pytest-docker/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/avast%2Fpytest-docker/sbom","scorecard":{"id":13342,"data":{"date":"2025-08-11","repo":{"name":"github.com/avast/pytest-docker","commit":"65acfe2c8cd913d338e10ef420d8d07b74434899"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":4.6,"checks":[{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Maintained","score":3,"reason":"4 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 3","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Code-Review","score":5,"reason":"Found 17/29 approved changesets -- score normalized to 5","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/build-and-publish.yaml:1","Warn: no topLevel permission defined: .github/workflows/tests.yaml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE.txt:0","Info: FSF or OSI recognized license: MIT License: LICENSE.txt:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/build-and-publish.yaml:15: update your workflow using https://app.stepsecurity.io/secureworkflow/avast/pytest-docker/build-and-publish.yaml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/build-and-publish.yaml:16: update your workflow using https://app.stepsecurity.io/secureworkflow/avast/pytest-docker/build-and-publish.yaml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/tests.yaml:14: update your workflow using https://app.stepsecurity.io/secureworkflow/avast/pytest-docker/tests.yaml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/tests.yaml:16: update your workflow using https://app.stepsecurity.io/secureworkflow/avast/pytest-docker/tests.yaml/master?enable=pin","Warn: containerImage not pinned by hash: tests/containers/hello/Dockerfile:3: pin your Docker image by updating python:3.6-alpine to python:3.6-alpine@sha256:579978dec4602646fe1262f02b96371779bfb0294e92c91392707fa999c0c989","Warn: pipCommand not pinned by hash: .github/workflows/build-and-publish.yaml:21","Warn: pipCommand not pinned by hash: .github/workflows/tests.yaml:21","Warn: pipCommand not pinned by hash: .github/workflows/tests.yaml:22","Warn: pipCommand not pinned by hash: .github/workflows/tests.yaml:23","Info:   0 out of   4 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   1 containerImage dependencies pinned","Info:   0 out of   4 pipCommand dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Branch-Protection","score":-1,"reason":"internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration","details":null,"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 21 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-14T15:07:10.656Z","repository_id":40248717,"created_at":"2025-08-14T15:07:10.657Z","updated_at":"2025-08-14T15:07:10.657Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31559806,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-08T14:31:17.711Z","status":"ssl_error","status_checked_at":"2026-04-08T14:31:17.202Z","response_time":54,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5: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":[],"created_at":"2024-07-31T15:01:07.562Z","updated_at":"2026-04-08T14:32:33.607Z","avatar_url":"https://github.com/avast.png","language":"Python","readme":"Docker-based integration tests\n=====\n\n[![PyPI version](https://img.shields.io/pypi/v/pytest-docker?color=green)](https://pypi.org/project/pytest-docker/)\n[![Build Status](https://github.com/avast/pytest-docker/actions/workflows/tests.yaml/badge.svg?branch=master)](https://github.com/avast/pytest-docker/actions/workflows/tests.yaml)\n[![Python versions](https://img.shields.io/pypi/pyversions/pytest-docker)](https://pypi.org/project/pytest-docker/)\n[![Code style](https://img.shields.io/badge/formatted%20with-black-black)](https://github.com/psf/black)\n\n# Description\n\nSimple [pytest](http://doc.pytest.org/) fixtures that help you write integration\ntests with Docker and [Docker Compose](https://docs.docker.com/compose/).\nSpecify all necessary containers in a `docker-compose.yml` file and\n`pytest-docker` will spin them up for the duration of your tests.\n\n`pytest-docker` was originally created by André Caron.\n\n# Installation\n\nInstall `pytest-docker` with `pip` or add it to your test requirements.\n\nBy default, it uses the `docker compose` command, so it relies on the Compose plugin for Docker (also called Docker Compose V2).\n\n## Docker Compose V1 compatibility\n\nIf you want to use the old `docker-compose` command (deprecated since July 2023, not receiving updates since 2021)\n then you can do it using the [`docker-compose-command`](#docker_compose_command) fixture:\n\n```python\n@pytest.fixture(scope=\"session\")\ndef docker_compose_command() -\u003e str:\n    return \"docker-compose\"\n```\n\nIf you want to use the pip-distributed version of `docker-compose` command, you can install it using\n\n```\npip install pytest-docker[docker-compose-v1]\n```\n\nAnother option could be usage of [`compose-switch`](https://github.com/docker/compose-switch).\n\n# Usage\n\nHere is an example of a test that depends on an HTTP service.\n\nWith a `docker-compose.yml` file like this (using the\n[httpbin](https://httpbin.org/) service):\n\n```yaml\nversion: '2'\nservices:\n  httpbin:\n    image: \"kennethreitz/httpbin\"\n    ports:\n      - \"8000:80\"\n```\n\nYou can write a test like this:\n\n```python\nimport pytest\nimport requests\n\nfrom requests.exceptions import ConnectionError\n\n\ndef is_responsive(url):\n    try:\n        response = requests.get(url)\n        if response.status_code == 200:\n            return True\n    except ConnectionError:\n        return False\n\n\n@pytest.fixture(scope=\"session\")\ndef http_service(docker_ip, docker_services):\n    \"\"\"Ensure that HTTP service is up and responsive.\"\"\"\n\n    # `port_for` takes a container port and returns the corresponding host port\n    port = docker_services.port_for(\"httpbin\", 80)\n    url = \"http://{}:{}\".format(docker_ip, port)\n    docker_services.wait_until_responsive(\n        timeout=30.0, pause=0.1, check=lambda: is_responsive(url)\n    )\n    return url\n\n\ndef test_status_code(http_service):\n    status = 418\n    response = requests.get(http_service + \"/status/{}\".format(status))\n\n    assert response.status_code == status\n```\n\n\u003e The default `docker_setup` command includes `--wait`, which respects either the\n\u003e image `HEALTHCHECK` or the compose `healthcheck`. Generally, if those\n\u003e are configured properly, `wait_until_responsive` should not be required. \n\nBy default, this plugin will try to open `docker-compose.yml` in your\n`tests` directory. If you need to use a custom location, override the\n`docker_compose_file` fixture inside your `conftest.py` file:\n\n```python\nimport os\nimport pytest\n\n\n@pytest.fixture(scope=\"session\")\ndef docker_compose_file(pytestconfig):\n    return os.path.join(str(pytestconfig.rootdir), \"mycustomdir\", \"docker-compose.yml\")\n```\n\nTo use [multiple compose files](https://docs.docker.com/compose/how-tos/multiple-compose-files/merge/),\nreturn a list of paths from the `docker_compose_file` fixture:\n\n```python\nimport os\nimport pytest\n\n\n@pytest.fixture(scope=\"session\")\ndef docker_compose_file(pytestconfig):\n    return [\n        os.path.join(str(pytestconfig.rootdir), \"tests\", \"compose.yml\"),\n        os.path.join(str(pytestconfig.rootdir), \"tests\", \"compose.override.yml\"),\n    ]\n```\n\nIf you want to debug the test suite in your IDE (Pycharm, VsCode, etc.) and need to stop the test, the stack will be left running.\nTo avoid creating multiple stacks, you can pin the project name and always teardown before starting a new stack:\n\n```python\nimport pytest\n\n# Pin the project name to avoid creating multiple stacks\n@pytest.fixture(scope=\"session\")\ndef docker_compose_project_name() -\u003e str:\n    return \"my-compose-project\"\n\n# Stop the stack before starting a new one\n@pytest.fixture(scope=\"session\")\ndef docker_setup():\n    return [\"down -v\", \"up --build --wait\"]\n```\n\n\n## Available fixtures\n\nBy default, the scope of the fixtures are `session` but can be changed with\n`pytest` command line option `--container-scope \u003cscope\u003e`:\n\n```bash\npytest --container-scope \u003cscope\u003e \u003ctest_directory\u003e\n```\n\nFor available scopes and descriptions\nsee \u003chttps://docs.pytest.org/en/6.2.x/fixture.html#fixture-scopes\u003e\n\n### `docker_ip`\n\nDetermine the IP address for TCP connections to Docker containers.\n\n### `docker_compose_file`\n\nGet an absolute path to the  `docker-compose.yml` file. Override this fixture in\nyour tests if you need a custom location.\n\n### `docker_compose_project_name`\n\nGenerate a project name using the current process PID. Override this fixture in\nyour tests if you need a particular project name.\n\n### `docker_services`\n\nStart all services from the docker compose file (`docker-compose up`).\nAfter test are finished, shutdown all services (`docker-compose down`).\n\n### `docker_compose_command`\n\nDocker Compose command to use to execute Dockers. Default is to use\nDocker Compose V2 (command is `docker compose`). If you want to use\nDocker Compose V1, change this fixture to return `docker-compose`.\n\n### `docker_setup`\n\nGet the list of docker_compose commands to be executed for test spawn actions.\nOverride this fixture in your tests if you need to change spawn actions.\nReturning anything that would evaluate to False will skip this command.\n\n### `docker_cleanup`\n\nGet the list of docker_compose commands to be executed for test clean-up actions.\nOverride this fixture in your tests if you need to change clean-up actions.\nReturning anything that would evaluate to False will skip this command.\n\n# Development\n\nUse of a virtual environment is recommended. See the\n[venv](https://docs.python.org/3/library/venv.html) package for more\ninformation.\n\nFirst, install `pytest-docker` and its test dependencies:\n\n```bash\npip install -e \".[tests]\"\n```\n\nRun tests with\n\n```bash\npytest -c setup.cfg\n```\n\nto make sure that the correct configuration is used. This is also how tests are\nrun in CI.\n\nUse [black](https://pypi.org/project/black/) with default settings for\nformatting. You can also use `pylint` with `setup.cfg` as the configuration\nfile as well as `mypy` for type checking.\n\n# Contributing\n\nThis `pytest` plug-in and its source code are made available to you under a MIT\nlicense. It is safe to use in commercial and closed-source applications. Read\nthe license for details!\n\nFound a bug? Think a new feature would make this plug-in more practical? We\nwelcome issues and pull requests!\n\nWhen creating a pull request, be sure to follow this projects conventions (see\nabove).\n","funding_links":[],"categories":["Python","Testing Tools"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Favast%2Fpytest-docker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Favast%2Fpytest-docker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Favast%2Fpytest-docker/lists"}