11import os
22import pytest
3- import asyncio
43
54from redisvl .redis .connection import RedisConnectionFactory
65from testcontainers .compose import DockerCompose
76
87
9-
108@pytest .fixture (scope = "session" , autouse = True )
119def redis_container (request ):
1210 """
1311 Create a unique Compose project for each xdist worker by setting
1412 COMPOSE_PROJECT_NAME. That prevents collisions on container/volume names.
1513 """
16- # In xdist, the config has "workerid" in workerinput. For the main (non-xdist)
17- # process, 'workerid' is often 'master' or something similar.
14+ # In xdist, the config has "workerid" in workerinput
1815 worker_id = request .config .workerinput .get ("workerid" , "master" )
1916
2017 # Set the Compose project name so containers do not clash across workers
@@ -26,21 +23,11 @@ def redis_container(request):
2623 compose_file_name = "docker-compose.yml" ,
2724 pull = True ,
2825 )
29-
3026 compose .start ()
3127
32- # If you mapped the container port 6379:6379 in docker-compose.yml,
33- # you might have collisions across workers. If you rely on ephemeral
34- # host ports, remove the `ports:` block in docker-compose.yml and do:
35- redis_host , redis_port = compose .get_service_host_and_port ("redis" , 6379 )
36- #redis_url = f"redis://{redis_host}:{redis_port}"
37- #os.environ["REDIS_URL"] = redis_url
38-
3928 yield compose
4029
4130 compose .stop ()
42- # Optionally, clean up the COMPOSE_PROJECT_NAME you set:
43- os .environ .pop ("COMPOSE_PROJECT_NAME" , None )
4431
4532
4633@pytest .fixture (scope = "session" )
0 commit comments