{"id":22915598,"url":"https://github.com/dcermak/pytest_container","last_synced_at":"2025-04-05T11:08:08.231Z","repository":{"id":36988104,"uuid":"412505837","full_name":"dcermak/pytest_container","owner":"dcermak","description":"Collection of pytest helpers and fixtures to test container images","archived":false,"fork":false,"pushed_at":"2025-03-28T13:31:24.000Z","size":1230,"stargazers_count":34,"open_issues_count":14,"forks_count":18,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-03-28T13:32:18.250Z","etag":null,"topics":["containers","hacktoberfest","pytest","testing"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-2.1","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dcermak.png","metadata":{"files":{"readme":"README.rst","changelog":"CHANGELOG.rst","contributing":"CONTRIBUTING.rst","funding":null,"license":"LICENSE","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}},"created_at":"2021-10-01T14:46:51.000Z","updated_at":"2025-01-14T07:35:54.000Z","dependencies_parsed_at":"2023-09-27T12:29:18.454Z","dependency_job_id":"59cf01d7-e689-4619-8fad-7866a5b9c1dd","html_url":"https://github.com/dcermak/pytest_container","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dcermak%2Fpytest_container","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dcermak%2Fpytest_container/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dcermak%2Fpytest_container/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dcermak%2Fpytest_container/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dcermak","download_url":"https://codeload.github.com/dcermak/pytest_container/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247325693,"owners_count":20920714,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["containers","hacktoberfest","pytest","testing"],"created_at":"2024-12-14T05:27:27.654Z","updated_at":"2025-04-05T11:08:08.212Z","avatar_url":"https://github.com/dcermak.png","language":"Python","readme":"Pytest container\n================\n\n.. image:: https://github.com/dcermak/pytest_container/actions/workflows/ci.yml/badge.svg\n           :target: https://github.com/dcermak/pytest_container/actions/workflows/ci.yml\n\n.. image:: https://github.com/dcermak/pytest_container/actions/workflows/codeql-analysis.yml/badge.svg\n           :target: https://github.com/dcermak/pytest_container/actions/workflows/codeql-analysis.yml\n\n.. image:: https://codecov.io/gh/dcermak/pytest_container/branch/main/graph/badge.svg?token=D16Q2PGL67\n           :target: https://codecov.io/gh/dcermak/pytest_container\n\n.. image:: https://app.fossa.com/api/projects/git%2Bgithub.com%2Fdcermak%2Fpytest_container.svg?type=shield\n           :target: https://app.fossa.com/projects/git%2Bgithub.com%2Fdcermak%2Fpytest_container?ref=badge_shield\n\n.. image:: https://img.shields.io/pypi/v/pytest-container\n           :alt: PyPI\n           :target: https://pypi.org/project/pytest-container/\n\nFind the latest documentation on `dcermak.github.io/pytest_container\n\u003chttps://dcermak.github.io/pytest_container/\u003e`_.\n\n``pytest_container`` is a `pytest \u003chttps://pytest.org\u003e`_ plugin\nto test container images via pytest fixtures and `testinfra\n\u003chttps://testinfra.readthedocs.io/en/latest/\u003e`_. It takes care of all the boring\ntasks, like spinning up containers, finding free ports and cleaning up after\ntests, and allows you to focus on implementing the actual tests.\n\nThe plugin automates the following tasks:\n\n- pull, launch, and stop containers\n- build containers using a ``Dockerfile``\n- wait for containers to become healthy before executing tests\n- bind exposed container ports to free ports on the host\n- mount volumes via temporary directories\n- parallel test execution through pytest-xdist\n- build dependent container images in the correct order\n- run the same test on as many container images as necessary\n- create, launch and destroy podman pods\n\n``pytest_container`` provides four fixtures that give you everything you need\nfor testing containers. Spinning up a container image can be as simple as\ninstantiating a ``Container`` and parametrizing a test function with the\n``container`` fixture:\n\n.. code-block:: python\n\n   TW = Container(url=\"registry.opensuse.org/opensuse/tumbleweed:latest\")\n\n   @pytest.mark.parametrize(\"container\", [TW], indirect=[\"container\"])\n   def test_etc_os_release_present(container: ContainerData):\n       assert container.connection.file(\"/etc/os-release\").exists\n\n\nThe fixture automatically pulls and spins up the container, stops it and removes\nit after the test is completed. Your test function receives an instance of\n``ContainerData`` with the ``ContainerData.connection`` attribute. The\n``ContainerData.connection`` attribute is a `testinfra\n\u003chttps://testinfra.readthedocs.io/en/latest/\u003e`_ connection object. It can be\nused to run basic tests inside the container itself. For example, you can check\nwhether files are present, packages are installed, etc.\n\n\nUse cases\n---------\n\n1. Run functional tests on operating system container images\n\n2. Verify your software on multiple operating systems\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdcermak%2Fpytest_container","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdcermak%2Fpytest_container","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdcermak%2Fpytest_container/lists"}