-
Notifications
You must be signed in to change notification settings - Fork 297
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into fix_image_kwargs
- Loading branch information
Showing
13 changed files
with
127 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
{ | ||
".": "4.8.2" | ||
".": "4.9.0" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
services: | ||
runs-always: &simple-service | ||
image: alpine:latest | ||
init: true | ||
command: | ||
- sh | ||
- -c | ||
- 'while true; do sleep 0.1 ; date -Ins; done' | ||
runs-profile-a: | ||
<<: *simple-service | ||
profiles: | ||
- profile-a | ||
runs-profile-b: | ||
<<: *simple-service | ||
profiles: | ||
- profile-b |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
import tempfile | ||
from pathlib import Path | ||
|
||
from testcontainers.core.container import DockerContainer | ||
|
||
|
||
|
@@ -17,3 +20,29 @@ def test_get_logs(): | |
assert isinstance(stdout, bytes) | ||
assert isinstance(stderr, bytes) | ||
assert "Hello from Docker".encode() in stdout, "There should be something on stdout" | ||
|
||
|
||
def test_docker_container_with_env_file(): | ||
"""Test that environment variables can be loaded from a file""" | ||
with tempfile.TemporaryDirectory() as temp_directory: | ||
env_file_path = Path(temp_directory) / "env_file" | ||
with open(env_file_path, "w") as f: | ||
f.write( | ||
""" | ||
TEST_ENV_VAR=hello | ||
NUMBER=123 | ||
DOMAIN=example.org | ||
ADMIN_EMAIL=admin@${DOMAIN} | ||
ROOT_URL=${DOMAIN}/app | ||
""" | ||
) | ||
container = DockerContainer("alpine").with_command("tail -f /dev/null") # Keep the container running | ||
container.with_env_file(env_file_path) # Load the environment variables from the file | ||
with container: | ||
output = container.exec("env").output.decode("utf-8").strip() | ||
assert "TEST_ENV_VAR=hello" in output | ||
assert "NUMBER=123" in output | ||
assert "DOMAIN=example.org" in output | ||
assert "[email protected]" in output | ||
assert "ROOT_URL=example.org/app" in output | ||
print(output) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[tool.poetry] | ||
name = "testcontainers" | ||
version = "4.8.2" # auto-incremented by release-please | ||
version = "4.9.0" # auto-incremented by release-please | ||
description = "Python library for throwaway instances of anything that can run in a Docker container" | ||
authors = ["Sergey Pirogov <[email protected]>"] | ||
maintainers = [ | ||
|
@@ -83,6 +83,7 @@ docker = "*" # ">=4.0" | |
urllib3 = "*" # "<2.0" | ||
wrapt = "*" # "^1.16.0" | ||
typing-extensions = "*" | ||
python-dotenv = "*" | ||
|
||
# community modules | ||
python-arango = { version = "^7.8", optional = true } | ||
|