7
7
from typing import Optional
8
8
from typing import Sequence
9
9
from typing import Tuple
10
- from typing import TYPE_CHECKING
11
10
from typing import Union
12
11
13
12
import iniconfig
17
16
from _pytest .pathlib import absolutepath
18
17
from _pytest .pathlib import commonpath
19
18
20
- if TYPE_CHECKING :
21
- from . import Config
22
-
23
19
24
20
def _parse_ini_config (path : Path ) -> iniconfig .IniConfig :
25
21
"""Parse the given generic '.ini' file using legacy IniConfig parser, returning
@@ -176,8 +172,21 @@ def determine_setup(
176
172
inifile : Optional [str ],
177
173
args : Sequence [str ],
178
174
rootdir_cmd_arg : Optional [str ] = None ,
179
- config : Optional ["Config" ] = None ,
175
+ invocation_dir : Optional [Path ] = None ,
180
176
) -> 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
+ """
181
190
rootdir = None
182
191
dirs = get_dirs_from_args (args )
183
192
if inifile :
@@ -198,8 +207,8 @@ def determine_setup(
198
207
if dirs != [ancestor ]:
199
208
rootdir , inipath , inicfg = locate_config (dirs )
200
209
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
203
212
else :
204
213
cwd = Path .cwd ()
205
214
rootdir = get_common_ancestor ([cwd , ancestor ])
0 commit comments