From 32ac7a7c6ecaaf21fde64e4997345a95367fd939 Mon Sep 17 00:00:00 2001 From: holger krekel Date: Mon, 1 Nov 2010 08:55:14 +0100 Subject: [PATCH] rename addargs to addopts, make adding of opts configurable --- doc/customize.txt | 4 ++-- pytest/__init__.py | 2 +- pytest/plugin/config.py | 9 +++++---- setup.py | 2 +- testing/plugin/test_terminal.py | 4 ++-- testing/test_config.py | 6 +++++- 6 files changed, 16 insertions(+), 11 deletions(-) diff --git a/doc/customize.txt b/doc/customize.txt index 0064517cf..fa70a0244 100644 --- a/doc/customize.txt +++ b/doc/customize.txt @@ -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:: diff --git a/pytest/__init__.py b/pytest/__init__.py index 78c4db933..43b1b505e 100644 --- a/pytest/__init__.py +++ b/pytest/__init__.py @@ -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'] diff --git a/pytest/plugin/config.py b/pytest/plugin/config.py index 5cc9cf612..56308ad77 100644 --- a/pytest/plugin/config.py +++ b/pytest/plugin/config.py @@ -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() diff --git a/setup.py b/setup.py index d17ed62ba..92a616b2f 100644 --- a/setup.py +++ b/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'], diff --git a/testing/plugin/test_terminal.py b/testing/plugin/test_terminal.py index 00e27222e..6861bc991 100644 --- a/testing/plugin/test_terminal.py +++ b/testing/plugin/test_terminal.py @@ -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") diff --git a/testing/test_config.py b/testing/test_config.py index d9a3b8692..8c046f111 100644 --- a/testing/test_config.py +++ b/testing/test_config.py @@ -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="""