Skip to content

Commit 1f50a62

Browse files
fixup
1 parent cae5648 commit 1f50a62

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

core/testcontainers/core/container.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ def maybe_emulate_amd64(self) -> Self:
8888
return self
8989

9090
def start(self) -> Self:
91+
breakpoint()
9192
def _start():
9293
docker_client = self.get_docker_client()
9394
self._container = docker_client.run(
@@ -146,8 +147,7 @@ def _start():
146147
def stop(self, force=True, delete_volume=True) -> None:
147148
if self._container:
148149
if self._reuse and c.reuse_enabled:
149-
#self._container.stop()
150-
return
150+
self._container.stop()
151151
else:
152152
self._container.remove(force=force, v=delete_volume)
153153
self.get_docker_client().client.close()

core/tests/test_reusable_containers.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,21 @@ def test_docker_container_with_reuse_reuse_disabled():
2020
assert id not in [container.id for container in containers]
2121

2222

23-
def test_docker_container_with_reuse_reuse_enabled(monkeypatch):
23+
def test_docker_container_with_reuse_reuse_enabled_ryuk_enabled(monkeypatch):
24+
monkeypatch.setattr("testcontainers.core.config.testcontainers_config.reuse_enabled", True)
25+
with DockerContainer("hello-world").with_reuse() as container:
26+
assert container._reuse == True
27+
id = container._container.id
28+
containers = DockerClient().client.containers.list(all=True)
29+
assert id in [container.id for container in containers]
30+
31+
32+
# TODO: do not run test while ryuk is running
33+
# TODO: clean up container after test run
34+
def test_docker_container_with_reuse_reuse_enabled_ryuk_diabled(monkeypatch):
2435
monkeypatch.setattr("testcontainers.core.config.testcontainers_config.reuse_enabled", True)
2536
monkeypatch.setattr("testcontainers.core.config.testcontainers_config.ryuk_disabled", True)
26-
with DockerContainer("postgres", auto_remove=False).with_reuse() as container:
37+
with DockerContainer("hello-world").with_reuse() as container:
2738
assert container._reuse == True
2839
id = container._container.id
2940
containers = DockerClient().client.containers.list(all=True)

0 commit comments

Comments
 (0)