Skip to main content

context manager that runs and closes docker containers

Project description

dockontext

pypi Build Status codecov

context manager that runs and closes docker containers

Features

  • 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.

Example

with pytest.fixture

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 will be created and the name is 'dockontext-{name}'
     async with docker_context(name, "alpine:latest") as container:
         result = await container.execute(name, timeout: float)
         assert result == Result(returncode=0, stdout="hello\n", stderr="")
     # container will be stopped and removed here

with contextlib.asynccontextmanager

from contextlib import asynccontextmanager
from dockontext import container_generator_from_image, Result

docker_context = asynccontextmanager(container_generator_from_image)

TODO

  • Dockerfile
  • docker-compose.yml
  • container group context
  • get ip

Free software: MIT License

Credits

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.0.tar.gz (4.0 kB view hashes)

Uploaded Source

Built Distribution

dockontext-0.1.0-py3-none-any.whl (4.5 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page