def test_docker_kargs(): code_dir = Path(__file__).parent container_first = GenericContainer("nginx:latest") container_first.with_volume_mapping(code_dir, '/code') container_second = GenericContainer("nginx:latest") with container_first: container_second.with_kargs(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_docker_parameters_using_kwargs(): code_dir = Path(__file__).parent container_first = GenericContainer("nginx:latest") container_first.with_volume_mapping(code_dir, '/code') container_second = GenericContainer("nginx:latest", working_dir='/code') print(container_second._kwargs) 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 pwd_first = container_first.exec('pwd').output.decode( 'utf-8').strip() pwd_second = container_second.exec('pwd').output.decode( 'utf-8').strip() assert pwd_first != pwd_second assert pwd_second == '/code'