Skip to content

Commit

Permalink
Make more use of get_dirs_from_args
Browse files Browse the repository at this point in the history
  • Loading branch information
blueyed committed Jun 21, 2016
1 parent e784bca commit 2ceea07
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions _pytest/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -1121,26 +1121,27 @@ def get_common_ancestor(args):
return common_ancestor

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

def determine_setup(inifile, args):
dirs = get_dirs_from_args(args)
if inifile:
iniconfig = py.iniconfig.IniConfig(inifile)
try:
inicfg = iniconfig["pytest"]
except KeyError:
inicfg = None
rootdir = get_common_ancestor(args)
rootdir = get_common_ancestor(dirs)
else:
ancestor = get_common_ancestor(args)
ancestor = get_common_ancestor(dirs)
rootdir, inifile, inicfg = getcfg(
[ancestor], ["pytest.ini", "tox.ini", "setup.cfg"])
if rootdir is None:
for rootdir in ancestor.parts(reverse=True):
if rootdir.join("setup.py").exists():
break
else:
dirs = get_dirs_from_args(args)
rootdir, inifile, inicfg = getcfg(
dirs, ["pytest.ini", "tox.ini", "setup.cfg"])
if rootdir is None:
Expand Down

0 comments on commit 2ceea07

Please sign in to comment.