{"id":17464327,"url":"https://github.com/sylvainmouquet/pydocks","last_synced_at":"2025-04-19T20:02:38.552Z","repository":{"id":257801531,"uuid":"863135531","full_name":"sylvainmouquet/pydocks","owner":"sylvainmouquet","description":"Pytest fixures for running tests with Docker containers","archived":false,"fork":false,"pushed_at":"2024-12-20T07:09:14.000Z","size":514,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-12-22T20:03:20.046Z","etag":null,"topics":["containers","docker","postgresql","pytest","tests","vault"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/pydocks","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/sylvainmouquet.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-09-25T19:19:06.000Z","updated_at":"2024-12-16T18:32:54.000Z","dependencies_parsed_at":null,"dependency_job_id":"a812950f-2beb-43f7-b076-88bb7ecd658a","html_url":"https://github.com/sylvainmouquet/pydocks","commit_stats":null,"previous_names":["sylvainmouquet/pydocks"],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sylvainmouquet%2Fpydocks","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sylvainmouquet%2Fpydocks/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sylvainmouquet%2Fpydocks/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sylvainmouquet%2Fpydocks/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sylvainmouquet","download_url":"https://codeload.github.com/sylvainmouquet/pydocks/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240409837,"owners_count":19796795,"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","docker","postgresql","pytest","tests","vault"],"created_at":"2024-10-18T10:45:23.785Z","updated_at":"2025-04-19T20:02:38.524Z","avatar_url":"https://github.com/sylvainmouquet.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PyDocks\n\nPyDocks is a group of pytest fixures for running tests with Docker containers\n\n### Demonstration:\n\n```python\nimport pytest\nimport asyncpg\n\n@pytest.mark.asyncio\nasync def test_postgresql_execute_command(postgresql_container):\n    # Connect to the PostgreSQL database\n    conn = await asyncpg.connect(\n        host=\"127.0.0.1\",\n        port=5433,\n        user=\"postgres\",\n        password=\"postgres\",\n        database=\"postgres\",\n    )\n\n    try:\n        # Execute a simple command\n        result = await conn.fetchval(\"SELECT 1\")\n        assert result == 1, \"Failed to execute command on PostgreSQL\"\n    finally:\n        # Close the connection\n        await conn.close()\n\n```\n\n## Table of Contents\n\n- [PyDocks](#PyDocks)\n  - [Table of Contents](#table-of-contents)\n  - [Description](#description)\n  - [Installation](#installation)\n  - [Usage](#usage)\n  - [License](#license)\n  - [Contact](#contact)\n\n## Description\n\nPyDocks is a Python library that provides a set of pytest fixtures for running tests with Docker containers. It simplifies the process of setting up, managing, and tearing down Docker containers during test execution.\n\nKey features include:\n- Easy integration with pytest\n- Support for PostgreSQL, Hashicorp Vault containers, Redis\n- Automatic container cleanup\n- Configurable container settings\n- Reusable session-scoped containers for improved test performance\n\nPyDocks is designed to make testing with Docker containers more efficient and less error-prone, allowing developers to focus on writing tests rather than managing infrastructure.\n\n## Installation\n\n```bash\n# Install the dependency\npip install pydocks\nuv add pydocks\npoetry add pydocks\n```\n\n## Usage\n\n### Remove all old containers\n```python\nimport pytest\nimport pytest_asyncio\nfrom loguru import logger\n\n@pytest_asyncio.fixture(scope=\"session\", loop_scope=\"session\", autouse=True)\nasync def begin_clean_all_containers(postgresql_clean_all_containers):\n    logger.info(\"Begin - clean all containers\")\n```\n\n### Use a function container\n```python\nimport pytest\n\n@pytest.mark.asyncio\nasync def test_postgresql_execute_command(postgresql_container):\n  ...\n```\n\n### Use a session container, to keep the container to use it in multiple tests\n```python\nimport pytest\n\n@pytest.mark.asyncio(loop_scope=\"session\")\nasync def test_reuse_postgresql_container_1_2(postgresql_container_session):\n  ...\n  # postgresql_container_session creates a new container\n\n@pytest.mark.asyncio(loop_scope=\"session\")\nasync def test_reuse_postgresql_container_2_2(postgresql_container_session):\n  ...\n  # postgresql_container_session uses the same instance of container created in test_reuse_postgresql_container_1_2\n```\n\n\n## License\n\nPyDocks is released under the MIT License. See the [LICENSE](LICENSE) file for more details.\n\n## Contact\n\nFor questions, suggestions, or issues related to PyDocks, please open an issue on the GitHub repository.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsylvainmouquet%2Fpydocks","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsylvainmouquet%2Fpydocks","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsylvainmouquet%2Fpydocks/lists"}