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 def test_fixture(docker_context):
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
- get ip
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.1.tar.gz
(4.3 kB
view hashes)
Built Distribution
Close
Hashes for dockontext-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 03b2f688b566ecedbe96d6e3dae61304e64f78323ff9d8561bfe0fa9d4955980 |
|
MD5 | ab7a94c484cb3f2d0acefedf5d97ebcc |
|
BLAKE2b-256 | 6e6ae34bf4636f43cf16d99f524cb00919122fc44083282641650ee2a16ba7db |