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
|
||||
|
||||
.. confval:: addargs = OPTS
|
||||
.. confval:: addopts = OPTS
|
||||
|
||||
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::
|
||||
|
||||
[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::
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ see http://pytest.org for documentation and details
|
|||
|
||||
(c) Holger Krekel and others, 2004-2010
|
||||
"""
|
||||
__version__ = '2.0.0.dev15'
|
||||
__version__ = '2.0.0.dev16'
|
||||
|
||||
__all__ = ['config', 'cmdline']
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ def pytest_cmdline_parse(pluginmanager, args):
|
|||
return config
|
||||
|
||||
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')
|
||||
|
||||
class Parser:
|
||||
|
@ -292,10 +292,11 @@ class Config(object):
|
|||
sys.stderr.write(err)
|
||||
raise
|
||||
|
||||
def _preparse(self, args):
|
||||
def _preparse(self, args, addopts=True):
|
||||
self.inicfg = {}
|
||||
self.inicfg = getcfg(args, ["setup.cfg", "tox.ini",])
|
||||
if self.inicfg:
|
||||
newargs = self.inicfg.get("addargs", None)
|
||||
if self.inicfg and addopts:
|
||||
newargs = self.inicfg.get("addopts", None)
|
||||
if newargs:
|
||||
args[:] = py.std.shlex.split(newargs) + args
|
||||
self._checkversion()
|
||||
|
|
2
setup.py
2
setup.py
|
@ -22,7 +22,7 @@ def main():
|
|||
name='pytest',
|
||||
description='py.test: simple powerful testing with Python',
|
||||
long_description = long_description,
|
||||
version='2.0.0.dev15',
|
||||
version='2.0.0.dev16',
|
||||
url='http://pytest.org',
|
||||
license='MIT license',
|
||||
platforms=['unix', 'linux', 'osx', 'cygwin', 'win32'],
|
||||
|
|
|
@ -475,8 +475,8 @@ def test_getreportopt():
|
|||
config.option.reportchars = "sfx"
|
||||
assert getreportopt(config) == "sfx"
|
||||
|
||||
def test_terminalreporter_reportopt_addargs(testdir):
|
||||
testdir.makeini("[pytest]\naddargs=-rs")
|
||||
def test_terminalreporter_reportopt_addopts(testdir):
|
||||
testdir.makeini("[pytest]\naddopts=-rs")
|
||||
p = testdir.makepyfile("""
|
||||
def pytest_funcarg__tr(request):
|
||||
tr = request.config.pluginmanager.getplugin("terminalreporter")
|
||||
|
|
|
@ -19,11 +19,15 @@ class TestParseIni:
|
|||
def test_append_parse_args(self, tmpdir):
|
||||
tmpdir.join("setup.cfg").write(py.code.Source("""
|
||||
[pytest]
|
||||
addargs = --verbose
|
||||
addopts = --verbose
|
||||
"""))
|
||||
config = Config()
|
||||
config.parse([tmpdir])
|
||||
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):
|
||||
p = testdir.makefile('.ini', tox="""
|
||||
|
|
Loading…
Reference in New Issue