77from typing import Optional
88from typing import Sequence
99from typing import Tuple
10- from typing import TYPE_CHECKING
1110from typing import Union
1211
1312import iniconfig
1716from _pytest .pathlib import absolutepath
1817from _pytest .pathlib import commonpath
1918
20- if TYPE_CHECKING :
21- from . import Config
22-
2319
2420def _parse_ini_config (path : Path ) -> iniconfig .IniConfig :
2521 """Parse the given generic '.ini' file using legacy IniConfig parser, returning
@@ -176,8 +172,21 @@ def determine_setup(
176172 inifile : Optional [str ],
177173 args : Sequence [str ],
178174 rootdir_cmd_arg : Optional [str ] = None ,
179- config : Optional ["Config" ] = None ,
175+ invocation_dir : Optional [Path ] = None ,
180176) -> Tuple [Path , Optional [Path ], Dict [str , Union [str , List [str ]]]]:
177+ """Determine the rootdir, inifile and ini configuration values from the
178+ command line arguments.
179+
180+ :param inifile:
181+ The `--inifile` command line argument, if given.
182+ :param args:
183+ The free command line arguments.
184+ :param rootdir_cmd_arg:
185+ The `--rootdir` command line argument, if given.
186+ :param invocation_dir:
187+ The working directory when pytest was invoked, if known.
188+ If not known, the current working directory is used.
189+ """
181190 rootdir = None
182191 dirs = get_dirs_from_args (args )
183192 if inifile :
@@ -198,8 +207,8 @@ def determine_setup(
198207 if dirs != [ancestor ]:
199208 rootdir , inipath , inicfg = locate_config (dirs )
200209 if rootdir is None :
201- if config is not None :
202- cwd = config . invocation_params . dir
210+ if invocation_dir is not None :
211+ cwd = invocation_dir
203212 else :
204213 cwd = Path .cwd ()
205214 rootdir = get_common_ancestor ([cwd , ancestor ])
0 commit comments