@@ -28,6 +28,31 @@ def test_read_tc_properties(monkeypatch: MonkeyPatch) -> None:
28
28
assert config .tc_properties == {"tc.host" : "some_value" }
29
29
30
30
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
+
31
56
@mark .parametrize ("docker_auth_config_env" , ["key=value" , "" ])
32
57
@mark .parametrize ("warning_dict" , [{}, {"key" : "value" }, {"DOCKER_AUTH_CONFIG" : "TEST" }])
33
58
@mark .parametrize ("warning_dict_post" , [{}, {"key" : "value" }, {"DOCKER_AUTH_CONFIG" : "TEST" }])
0 commit comments