Skip to content

Commit 2ceea07

Browse files
committed
Make more use of get_dirs_from_args
1 parent e784bca commit 2ceea07

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

_pytest/config.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1121,26 +1121,27 @@ def get_common_ancestor(args):
11211121
return common_ancestor
11221122

11231123
def get_dirs_from_args(args):
1124-
return [py.path.local(x) for x in args if not str(x).startswith("-")]
1124+
return [d for d in (py.path.local(x) for x in args if not
1125+
str(x).startswith("-")) if d.exists()]
11251126

11261127
def determine_setup(inifile, args):
1128+
dirs = get_dirs_from_args(args)
11271129
if inifile:
11281130
iniconfig = py.iniconfig.IniConfig(inifile)
11291131
try:
11301132
inicfg = iniconfig["pytest"]
11311133
except KeyError:
11321134
inicfg = None
1133-
rootdir = get_common_ancestor(args)
1135+
rootdir = get_common_ancestor(dirs)
11341136
else:
1135-
ancestor = get_common_ancestor(args)
1137+
ancestor = get_common_ancestor(dirs)
11361138
rootdir, inifile, inicfg = getcfg(
11371139
[ancestor], ["pytest.ini", "tox.ini", "setup.cfg"])
11381140
if rootdir is None:
11391141
for rootdir in ancestor.parts(reverse=True):
11401142
if rootdir.join("setup.py").exists():
11411143
break
11421144
else:
1143-
dirs = get_dirs_from_args(args)
11441145
rootdir, inifile, inicfg = getcfg(
11451146
dirs, ["pytest.ini", "tox.ini", "setup.cfg"])
11461147
if rootdir is None:

0 commit comments

Comments
 (0)