Skip to content

Commit

Permalink
fix(core): add empty _configure to DockerContainer (#556)
Browse files Browse the repository at this point in the history
I've used DbContainer in the past as a parent to a class where I
redefined `_configure()` and did not redefine `start()`. I'm now using
DockerContainer and wanted to follow the same pattern but it doesn't
have a `_configure()` function called in `start()`. I figure this gives
the easy option without being invasive?

tests pass

---------

Co-authored-by: David Ankin <daveankin@gmail.com>
  • Loading branch information
christianaaronschroeder and alexanderankin committed May 14, 2024
1 parent 3c8006c commit 08916c8
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions core/testcontainers/core/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ def start(self) -> Self:
Reaper.get_instance()
logger.info("Pulling image %s", self.image)
docker_client = self.get_docker_client()
self._configure()
self._container = docker_client.run(
self.image,
command=self._command,
Expand Down Expand Up @@ -176,6 +177,10 @@ def exec(self, command) -> tuple[int, str]:
raise ContainerStartException("Container should be started before executing a command")
return self._container.exec_run(command)

def _configure(self) -> None:
# placeholder if subclasses want to define this and use the default start method
pass


class Reaper:
_instance: "Optional[Reaper]" = None
Expand Down

0 comments on commit 08916c8

Please sign in to comment.