def test_docker_kwargs(): code_dir = Path(__file__).parent container_first = DockerContainer("nginx:latest") container_first.with_volume_mapping(code_dir, '/code') container_second = DockerContainer("nginx:latest") with container_first: container_second.with_kwargs(volumes_from=[container_first._container.short_id]) with container_second: files_first = container_first.exec('ls /code').output.decode('utf-8').strip() files_second = container_second.exec('ls /code').output.decode('utf-8').strip() assert files_first == files_second
def test_container_environments(): code_dir = Path(__file__).parent container = DockerContainer("nginx:latest") container.with_env('TEST', 'test') container.with_env('DOCKER', 'docker') with container: output = container.exec("bash -c 'echo $TEST $DOCKER'").output.decode( 'utf-8').strip() assert output == 'test docker'