Implement the "-c" command line switch that allows to explicitly specifiy the config file to load.

This feature was requested in issue #174.

--HG--
branch : explicit-ini-filename
This commit is contained in:
christian@christian-linux.sarrazin.local
2014-06-27 17:42:37 +02:00
parent 54c88a6cf3
commit c8264385ea
3 changed files with 26 additions and 0 deletions

View File

@@ -833,6 +833,14 @@ def exists(path, ignore=EnvironmentError):
return False
def getcfg(args, inibasenames):
if "-c" in args:
n = len(args)
for i in range(1, n):
if args[i - 1] == "-c" and not str(args[i]).startswith("-"):
iniconfig = py.iniconfig.IniConfig(args[i])
if 'pytest' in iniconfig.sections:
return iniconfig['pytest']
return {}
args = [x for x in args if not str(x).startswith("-")]
if not args:
args = [py.path.local()]