rename addargs to addopts, make adding of opts configurable
This commit is contained in:
parent
85c24b7fa1
commit
32ac7a7c6e
|
@ -45,13 +45,13 @@ builtin configuration file options
|
||||||
|
|
||||||
minversion = 2.1 # will fail if we run with pytest-2.0
|
minversion = 2.1 # will fail if we run with pytest-2.0
|
||||||
|
|
||||||
.. confval:: addargs = OPTS
|
.. confval:: addopts = OPTS
|
||||||
|
|
||||||
add the specified ``OPTS`` to the set of command line arguments as if they
|
add the specified ``OPTS`` to the set of command line arguments as if they
|
||||||
had been specified by the user. Example: if you have this ini file content::
|
had been specified by the user. Example: if you have this ini file content::
|
||||||
|
|
||||||
[pytest]
|
[pytest]
|
||||||
addargs = --maxfail=2 -rf # exit after 2 failures, report fail info
|
addopts = --maxfail=2 -rf # exit after 2 failures, report fail info
|
||||||
|
|
||||||
issuing ``py.test test_hello.py`` actually means::
|
issuing ``py.test test_hello.py`` actually means::
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ see http://pytest.org for documentation and details
|
||||||
|
|
||||||
(c) Holger Krekel and others, 2004-2010
|
(c) Holger Krekel and others, 2004-2010
|
||||||
"""
|
"""
|
||||||
__version__ = '2.0.0.dev15'
|
__version__ = '2.0.0.dev16'
|
||||||
|
|
||||||
__all__ = ['config', 'cmdline']
|
__all__ = ['config', 'cmdline']
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ def pytest_cmdline_parse(pluginmanager, args):
|
||||||
return config
|
return config
|
||||||
|
|
||||||
def pytest_addoption(parser):
|
def pytest_addoption(parser):
|
||||||
parser.addini('addargs', 'default command line arguments')
|
parser.addini('addopts', 'default command line arguments')
|
||||||
parser.addini('minversion', 'minimally required pytest version')
|
parser.addini('minversion', 'minimally required pytest version')
|
||||||
|
|
||||||
class Parser:
|
class Parser:
|
||||||
|
@ -292,10 +292,11 @@ class Config(object):
|
||||||
sys.stderr.write(err)
|
sys.stderr.write(err)
|
||||||
raise
|
raise
|
||||||
|
|
||||||
def _preparse(self, args):
|
def _preparse(self, args, addopts=True):
|
||||||
|
self.inicfg = {}
|
||||||
self.inicfg = getcfg(args, ["setup.cfg", "tox.ini",])
|
self.inicfg = getcfg(args, ["setup.cfg", "tox.ini",])
|
||||||
if self.inicfg:
|
if self.inicfg and addopts:
|
||||||
newargs = self.inicfg.get("addargs", None)
|
newargs = self.inicfg.get("addopts", None)
|
||||||
if newargs:
|
if newargs:
|
||||||
args[:] = py.std.shlex.split(newargs) + args
|
args[:] = py.std.shlex.split(newargs) + args
|
||||||
self._checkversion()
|
self._checkversion()
|
||||||
|
|
2
setup.py
2
setup.py
|
@ -22,7 +22,7 @@ def main():
|
||||||
name='pytest',
|
name='pytest',
|
||||||
description='py.test: simple powerful testing with Python',
|
description='py.test: simple powerful testing with Python',
|
||||||
long_description = long_description,
|
long_description = long_description,
|
||||||
version='2.0.0.dev15',
|
version='2.0.0.dev16',
|
||||||
url='http://pytest.org',
|
url='http://pytest.org',
|
||||||
license='MIT license',
|
license='MIT license',
|
||||||
platforms=['unix', 'linux', 'osx', 'cygwin', 'win32'],
|
platforms=['unix', 'linux', 'osx', 'cygwin', 'win32'],
|
||||||
|
|
|
@ -475,8 +475,8 @@ def test_getreportopt():
|
||||||
config.option.reportchars = "sfx"
|
config.option.reportchars = "sfx"
|
||||||
assert getreportopt(config) == "sfx"
|
assert getreportopt(config) == "sfx"
|
||||||
|
|
||||||
def test_terminalreporter_reportopt_addargs(testdir):
|
def test_terminalreporter_reportopt_addopts(testdir):
|
||||||
testdir.makeini("[pytest]\naddargs=-rs")
|
testdir.makeini("[pytest]\naddopts=-rs")
|
||||||
p = testdir.makepyfile("""
|
p = testdir.makepyfile("""
|
||||||
def pytest_funcarg__tr(request):
|
def pytest_funcarg__tr(request):
|
||||||
tr = request.config.pluginmanager.getplugin("terminalreporter")
|
tr = request.config.pluginmanager.getplugin("terminalreporter")
|
||||||
|
|
|
@ -19,11 +19,15 @@ class TestParseIni:
|
||||||
def test_append_parse_args(self, tmpdir):
|
def test_append_parse_args(self, tmpdir):
|
||||||
tmpdir.join("setup.cfg").write(py.code.Source("""
|
tmpdir.join("setup.cfg").write(py.code.Source("""
|
||||||
[pytest]
|
[pytest]
|
||||||
addargs = --verbose
|
addopts = --verbose
|
||||||
"""))
|
"""))
|
||||||
config = Config()
|
config = Config()
|
||||||
config.parse([tmpdir])
|
config.parse([tmpdir])
|
||||||
assert config.option.verbose
|
assert config.option.verbose
|
||||||
|
config = Config()
|
||||||
|
args = [tmpdir,]
|
||||||
|
config._preparse(args, addopts=False)
|
||||||
|
assert len(args) == 1
|
||||||
|
|
||||||
def test_tox_ini_wrong_version(self, testdir):
|
def test_tox_ini_wrong_version(self, testdir):
|
||||||
p = testdir.makefile('.ini', tox="""
|
p = testdir.makefile('.ini', tox="""
|
||||||
|
|
Loading…
Reference in New Issue