Skip to content

Commit

Permalink
warn user if ryuk is disabled but with_reuse used
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiasschaub committed Jul 3, 2024
1 parent 6e3029e commit 7a7ea48
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions core/testcontainers/core/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,13 @@ def start(self) -> Self:
hash_ = hashlib.sha256(bytes(str(args), encoding="utf-8")).hexdigest()

# TODO: check also if ryuk is disabled
if self._reuse and not c.tc_properties_testcontainers_reuse_enable:
if self._reuse and (not c.tc_properties_testcontainers_reuse_enable or not c.ryuk_disabled):
logging.warning(
"Reuse was requested (`with_reuse`) but the environment does not "
+ "support the reuse of containers. To enable container reuse, add "
+ "the property 'testcontainers.reuse.enable=true' to a file at "
+ "~/.testcontainers.properties (you may need to create it)."
+ "the 'testcontainers.reuse.enable=true' to "
+ "'~/.testcontainers.properties' and disable ryuk by setting the "
+ "environment variable 'TESTCONTAINERS_RYUK_DISABLED=true'"
)

if self._reuse and c.tc_properties_testcontainers_reuse_enable:
Expand Down

0 comments on commit 7a7ea48

Please sign in to comment.