Skip to content

Commit 18e09a7

Browse files
authored
Clarify container.remove() behaviour (#2235)
1 parent 1bbab5c commit 18e09a7

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

tagging/utils/docker_runner.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,8 @@ def __exit__(
3939
) -> None:
4040
assert self.container is not None
4141
LOGGER.info(f"Removing container {self.container.name} ...")
42-
if self.container:
43-
self.container.remove(force=True)
44-
LOGGER.info(f"Container {self.container.name} removed")
42+
self.container.remove(force=True)
43+
LOGGER.info(f"Container {self.container.name} removed")
4544

4645
@staticmethod
4746
def run_simple_command(

tests/utils/tracked_container.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,5 +92,9 @@ def _lines_starting_with(logs: str, pattern: str) -> list[str]:
9292

9393
def remove(self) -> None:
9494
"""Kills and removes the tracked docker container."""
95-
if self.container:
95+
if self.container is None:
96+
LOGGER.info("No container to remove")
97+
else:
98+
LOGGER.info(f"Removing container {self.container.name} ...")
9699
self.container.remove(force=True)
100+
LOGGER.info(f"Container {self.container.name} removed")

0 commit comments

Comments
 (0)