Skip to content

Commit

Permalink
Clarify container.remove() behaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
mathbunnyru committed Feb 22, 2025
1 parent 1bbab5c commit 5f57cb6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
5 changes: 2 additions & 3 deletions tagging/utils/docker_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,8 @@ def __exit__(
) -> None:
assert self.container is not None
LOGGER.info(f"Removing container {self.container.name} ...")
if self.container:
self.container.remove(force=True)
LOGGER.info(f"Container {self.container.name} removed")
self.container.remove(force=True)
LOGGER.info(f"Container {self.container.name} removed")

@staticmethod
def run_simple_command(
Expand Down
6 changes: 5 additions & 1 deletion tests/utils/tracked_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,5 +92,9 @@ def _lines_starting_with(logs: str, pattern: str) -> list[str]:

def remove(self) -> None:
"""Kills and removes the tracked docker container."""
if self.container:
if self.container is None:
LOGGER.info("No container to remove")
else:
LOGGER.info(f"Removing container {self.container.name} ...")
self.container.remove(force=True)
LOGGER.info(f"Container {self.container.name} removed")

0 comments on commit 5f57cb6

Please sign in to comment.