forked from testcontainers/testcontainers-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_new_docker_api.py
More file actions
28 lines (20 loc) · 967 Bytes
/
test_new_docker_api.py
File metadata and controls
28 lines (20 loc) · 967 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
from pathlib import Path
from testcontainers.core.container import DockerContainer
def test_docker_custom_image():
container = DockerContainer("mysql:5.7.17")
container.with_exposed_ports(3306)
container.with_env("MYSQL_ROOT_PASSWORD", "root")
with container:
port = container.get_exposed_port(3306)
assert int(port) > 0
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