File tree Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change 22
33from testcontainers .redis import RedisContainer , AsyncRedisContainer
44import pytest
5+ import redis
56
67
78def test_docker_run_redis ():
@@ -24,6 +25,16 @@ def test_docker_run_redis_with_password():
2425 assert client .get ("hello" ) == "world"
2526
2627
28+ def test_docker_run_start_fails (monkeypatch : pytest .MonkeyPatch ):
29+ # Patch config to speed up the test.
30+ monkeypatch .setattr ("testcontainers.core.config.testcontainers_config.max_tries" , 0.3 )
31+ monkeypatch .setattr ("testcontainers.core.config.testcontainers_config.sleep_time" , 0.02 )
32+ # Use a bogus image to make the startup check fail.
33+ config = RedisContainer (image = "hello-world" )
34+ with pytest .raises (redis .exceptions .ConnectionError , match = "Could not connect" ):
35+ config .start ()
36+
37+
2738pytest .mark .usefixtures ("anyio_backend" )
2839
2940
You can’t perform that action at this time.
0 commit comments