@@ -83,13 +83,12 @@ def test_docker_container_with_reuse_reuse_enabled(monkeypatch):
8383 container .stop ()
8484
8585
86- def test_docker_container_with_reuse_reuse_enabled_ryuk_disabled_same_id (monkeypatch ):
86+ def test_docker_container_with_reuse_reuse_enabled_same_id (monkeypatch ):
8787 # Make sure Ryuk cleanup is not active from previous test runs
8888 Reaper .delete_instance ()
8989
9090 tc_properties_mock = testcontainers_config .tc_properties | {"testcontainers.reuse.enable" : "true" }
9191 monkeypatch .setattr (testcontainers_config , "tc_properties" , tc_properties_mock )
92- monkeypatch .setattr (testcontainers_config , "ryuk_disabled" , True )
9392
9493 container_1 = DockerContainer ("hello-world" ).with_reuse ().start ()
9594 id_1 = container_1 ._container .id
@@ -102,8 +101,16 @@ def test_docker_container_with_reuse_reuse_enabled_ryuk_disabled_same_id(monkeyp
102101 # container_2.stop() is not needed since it is the same as container_1
103102
104103
105- def test_docker_container_labels_hash ():
106- expected_hash = "91fde3c09244e1d3ec6f18a225b9261396b9a1cb0f6365b39b9795782817c128"
104+ def test_docker_container_labels_hash_default ():
105+ # w/out reuse
106+ with DockerContainer ("hello-world" ) as container :
107+ assert container ._container .labels ["hash" ] == ""
108+
109+
110+ def test_docker_container_labels_hash (monkeypatch ):
111+ tc_properties_mock = testcontainers_config .tc_properties | {"testcontainers.reuse.enable" : "true" }
112+ monkeypatch .setattr (testcontainers_config , "tc_properties" , tc_properties_mock )
113+ expected_hash = "1bade17a9d8236ba71ffbb676f2ece3fb419ea0e6adb5f82b5a026213c431d8e"
107114 with DockerContainer ("hello-world" ).with_reuse () as container :
108115 assert container ._container .labels ["hash" ] == expected_hash
109116
@@ -113,7 +120,9 @@ def test_docker_client_find_container_by_hash_not_existing():
113120 assert DockerClient ().find_container_by_hash ("foo" ) == None
114121
115122
116- def test_docker_client_find_container_by_hash_existing ():
123+ def test_docker_client_find_container_by_hash_existing (monkeypatch ):
124+ tc_properties_mock = testcontainers_config .tc_properties | {"testcontainers.reuse.enable" : "true" }
125+ monkeypatch .setattr (testcontainers_config , "tc_properties" , tc_properties_mock )
117126 with DockerContainer ("hello-world" ).with_reuse () as container :
118127 hash_ = container ._container .labels ["hash" ]
119128 found_container = DockerClient ().find_container_by_hash (hash_ )
0 commit comments