Skip to content

Commit 116523d

Browse files
committed
Removed unused method, and added more test cases
1 parent d18904c commit 116523d

File tree

2 files changed

+25
-10
lines changed

2 files changed

+25
-10
lines changed

core/testcontainers/core/config.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,6 @@ def get_docker_socket() -> str:
4747
return "/var/run/docker.sock"
4848

4949

50-
def get_bool_env(name: str) -> bool:
51-
"""
52-
Get environment variable named `name` and convert it to bool.
53-
54-
Defaults to False.
55-
"""
56-
value = environ.get(name, "")
57-
return value.lower() in ENABLE_FLAGS
58-
59-
6050
TC_FILE = ".testcontainers.properties"
6151
TC_GLOBAL = Path.home() / TC_FILE
6252

core/tests/test_config.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,31 @@ def test_read_tc_properties(monkeypatch: MonkeyPatch) -> None:
2828
assert config.tc_properties == {"tc.host": "some_value"}
2929

3030

31+
def test_override_tc_properties(monkeypatch: MonkeyPatch) -> None:
32+
"""
33+
Ensure the configuration file variables can be read if no environment variable is set
34+
and ensure that we can re-set the configuration variables programattically to override
35+
testcontainers.properties
36+
"""
37+
with tempfile.TemporaryDirectory() as tmpdirname:
38+
file = f"{tmpdirname}/{TC_FILE}"
39+
with open(file, "w") as f:
40+
f.write("ryuk.disabled=true\n")
41+
f.write("ryuk.container.privileged=false\n")
42+
43+
monkeypatch.setattr("testcontainers.core.config.TC_GLOBAL", file)
44+
45+
config = TCC()
46+
assert config.ryuk_disabled == True
47+
assert config.ryuk_privileged == False
48+
49+
config.ryuk_disabled = False
50+
config.ryuk_privileged = True
51+
52+
assert config.ryuk_disabled == False
53+
assert config.ryuk_privileged == True
54+
55+
3156
@mark.parametrize("docker_auth_config_env", ["key=value", ""])
3257
@mark.parametrize("warning_dict", [{}, {"key": "value"}, {"DOCKER_AUTH_CONFIG": "TEST"}])
3358
@mark.parametrize("warning_dict_post", [{}, {"key": "value"}, {"DOCKER_AUTH_CONFIG": "TEST"}])

0 commit comments

Comments
 (0)