context manager that runs and closes docker containers
Project description
dockontext
context manager that runs and closes docker containers
- When integration or end-to-end test needs temporal docker container to fake remote systems, this package will help to create/close/remove the temporal docker container.
Features
- Create docker container by giving image name. The container will be named as 'docontext={name}'
- Close and remove the container when exit.
Example
with pytest.fixture (pytest-asyncio required)
import pytest
from dockontext import container_generator_from_image, Result
docker_context = pytest.fixture(container_generator_from_image)
@pytest.mark.asyncio
async def test_fixture(docker_context):
container = docker_context(name, "alpine:latest")
result = await container.execute("echo hello", timeout: float)
assert result == Result(returncode=0, stdout="hello\n", stderr="")
with contextlib.asynccontextmanager
from contextlib import asynccontextmanager
from dockontext import container_generator_from_image, Result
docker_context = asynccontextmanager(container_generator_from_image)
async with docker_context(name, "alpine:latest") as container:
result = await container.execute("echo hello", timeout: float)
assert result == Result(returncode=0, stdout="hello\n", stderr="")
TODO
- Dockerfile
- docker-compose.yml
- container group context
Free software: MIT License
Credits
- This package was created with Cookiecutter
- Also was copied and modified from the audreyr/cookiecutter-pypackage project template.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
dockontext-0.1.2.tar.gz
(4.4 kB
view hashes)
Built Distribution
Close
Hashes for dockontext-0.1.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8a322516a873dcb421b8ede3205a8cff82d4e9973bb351cb93c668278d1846a2 |
|
MD5 | 8570e9242620ab60bb3bd37103a87c72 |
|
BLAKE2b-256 | e30ba238ac63b4f340b31a1941711a1c280323ac32412a60c2519ce0c0c76e69 |