{"id":18507644,"url":"https://github.com/cans/python-docker-fixtures","last_synced_at":"2026-05-18T00:07:01.466Z","repository":{"id":45610243,"uuid":"221158112","full_name":"cans/python-docker-fixtures","owner":"cans","description":"Docker Containers as test fixtures made easy","archived":false,"fork":false,"pushed_at":"2023-01-14T22:37:49.000Z","size":88,"stargazers_count":0,"open_issues_count":4,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-17T17:31:02.565Z","etag":null,"topics":["container","docker","fixtures","python3","testing"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cans.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":"COPYING","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-11-12T07:38:27.000Z","updated_at":"2021-12-05T12:44:41.000Z","dependencies_parsed_at":"2023-02-09T20:35:15.037Z","dependency_job_id":null,"html_url":"https://github.com/cans/python-docker-fixtures","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/cans/python-docker-fixtures","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cans%2Fpython-docker-fixtures","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cans%2Fpython-docker-fixtures/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cans%2Fpython-docker-fixtures/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cans%2Fpython-docker-fixtures/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cans","download_url":"https://codeload.github.com/cans/python-docker-fixtures/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cans%2Fpython-docker-fixtures/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266856975,"owners_count":23995775,"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","status":"online","status_checked_at":"2025-07-24T02:00:09.469Z","response_time":99,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["container","docker","fixtures","python3","testing"],"created_at":"2024-11-06T15:10:25.455Z","updated_at":"2026-05-18T00:06:51.454Z","avatar_url":"https://github.com/cans.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"============================================\nDocker containers as test fixtures made easy\n============================================\n\n.. image:: https://badge.fury.io/py/dockerfixtures.svg\n    :alt: Latest version on Pypi: ?\n    :target: https://badge.fury.io/py/dockerfixtures\n.. image:: https://img.shields.io/pypi/pyversions/dockerfixtures.svg\n    :alt: Supported Python versions: ?\n    :target: https://pypi.org/project/dockerfixtures\n.. image:: https://travis-ci.com/cans/python-docker-fixtures.svg?branch=master\n    :alt: Build status (travis.com): ?\n    :target: https://travis-ci.com/cans/python-docker-fixtures\n.. image:: https://circleci.com/gh/cans/python-docker-fixtures.svg?style=svg\n    :alt: Build status (circleci.com): ?\n    :target: https://circleci.com/gh/cans/python-docker-fixtures\n.. image:: https://codecov.io/gh/cans/python-docker-fixtures/branch/master/graph/badge.svg\n    :alt: Test coverage: ? %\n    :target: https://codecov.io/gh/cans/python-docker-fixtures\n\n\nThis package was inspired by others, but after trying to make heads and tails\nof them when faced with bugs, I ended-up finding simpler to start over.\n\nUsing dockerfixtures with pytest\n================================\n\nTo spawn a container in your tests, proceed as follow:\n\n.. code-block:: Python\n\n    import docker\n    from dockerfixtures import image, container\n    import pytest\n\n    @pytest.fixture(scope='session')\n    def docker_client():\n         return docker.from_env()\n\n    @pytest.fixture(scope='session')\n    def pg_image() -\u003e image.Image:\n        return image.Image('postgres', tags='12')\n\n    @pytest.fixture(scope='function')\n    def pg_container(docker_client: docker.client.DockerClient,\n                     pg_image: image.Image) -\u003e container.Container:\n        yield from container.fixture(docker_client, some_image)\n\n    # If you don't need to reuse the image\n\n    @pytest.fixture(scope='session')\n    def pg_container(docker_client) -\u003e container.Container:\n        some_image = image.Image('postgres', tags='12')\n        yield from container.fixture(docker_client, some_image)\n\n\nWhy not a pytest plugin ?\n=========================\n\nOther implementation of this have been provinding a pytest\nplugin, so you might wonder why this one doesn't ?\n\nFirst reason is I have not looked into it that much, yet.\n\nBut anyhow, you would still need to import the\n``dockerfixtures.image`` module. So I am not very sure what the\nbenefits would be ?\n\nAlso I found those plugins to provide somewhat bizarre API, for\nexample to define the fixtures' scope. I haven't looked into\nwhy they do that, yet. Here there are no surprises, a container\nfixture looks like any other fixture.\n\nPytest plugins are global: they have to be imported in your\n`top-level`_ ``conftest.py`` (see note). I think it is good\npractice to keep your tests properly partitioned based on their\nexternal dependencies. It can help split workload if the need\narises. In a collaborative environment, having to import\n``dockerfixtures``, may help prevent breaking that partitioning\nduring reviews.\n\n\n.. _top-level: https://docs.pytest.org/en/latest/writing_plugins.html#requiring-loading-plugins-in-a-test-module-or-conftest-file\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcans%2Fpython-docker-fixtures","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcans%2Fpython-docker-fixtures","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcans%2Fpython-docker-fixtures/lists"}