2929import subprocess # noqa: S404
3030import sys
3131import timeit
32- from pathlib import Path
3332from typing import TYPE_CHECKING , Any , Callable
3433
3534import pytest
3837
3938if TYPE_CHECKING :
4039 from collections .abc import Awaitable , Generator
40+ from pathlib import Path
4141
4242
4343async def wait_until_responsive (
@@ -76,9 +76,9 @@ def __init__(self, worker_id: str, compose_project_name: str = COMPOSE_PROJECT_N
7676 self ._running_services : set [str ] = set ()
7777 self .docker_ip = self ._get_docker_ip ()
7878 self ._base_command = ["docker-compose" ] if USE_LEGACY_DOCKER_COMPOSE else ["docker" , "compose" ]
79+ self ._compose_files : list [str ] = []
7980 self ._base_command .extend (
8081 [
81- f"--file={ Path (__file__ ).parent / 'docker-compose.yml' } " ,
8282 f"--project-name={ compose_project_name } -{ worker_id } " ,
8383 ],
8484 )
@@ -96,12 +96,13 @@ def _get_docker_ip() -> str:
9696 raise ValueError (msg )
9797
9898 def run_command (self , * args : str ) -> None :
99- command = [* self ._base_command , * args ]
99+ command = [* self ._base_command , * self . _compose_files , * args ]
100100 subprocess .run (command , check = True , capture_output = True )
101101
102102 async def start (
103103 self ,
104104 name : str ,
105+ docker_compose_files : list [Path ],
105106 * ,
106107 check : Callable [..., Any ],
107108 timeout : float = 30 ,
@@ -111,6 +112,7 @@ async def start(
111112 if SKIP_DOCKER_COMPOSE :
112113 self ._running_services .add (name )
113114 if name not in self ._running_services :
115+ self ._compose_files = [f"--file={ compose_file } " for compose_file in docker_compose_files ]
114116 self .run_command ("up" , "--force-recreate" , "-d" , name )
115117 self ._running_services .add (name )
116118
0 commit comments