Add warning for incorrect passing args to `-o`.
This commit is contained in:
parent
e612619aea
commit
c856537e71
|
@ -1,6 +1,10 @@
|
||||||
3.0.5.dev0
|
3.0.5.dev0
|
||||||
==========
|
==========
|
||||||
|
|
||||||
|
* Add warning when not passing ``option=value`` correctly to ``-o/--override-ini`` (`#2105`_).
|
||||||
|
Also improved the help documentation. Thanks to `@mbukatov`_ for the report and
|
||||||
|
`@lwm`_ for the PR.
|
||||||
|
|
||||||
* Now ``--confcutdir`` and ``--junit-xml`` are properly validated if they are directories
|
* Now ``--confcutdir`` and ``--junit-xml`` are properly validated if they are directories
|
||||||
and filenames, respectively (`#2089`_ and `#2078`_). Thanks to `@lwm`_ for the PR.
|
and filenames, respectively (`#2089`_ and `#2078`_). Thanks to `@lwm`_ for the PR.
|
||||||
|
|
||||||
|
@ -30,6 +34,7 @@
|
||||||
|
|
||||||
*
|
*
|
||||||
|
|
||||||
|
.. _@mbukatov: https://github.com/mbukatov
|
||||||
.. _@dupuy: https://bitbucket.org/dupuy/
|
.. _@dupuy: https://bitbucket.org/dupuy/
|
||||||
.. _@lwm: https://github.com/lwm
|
.. _@lwm: https://github.com/lwm
|
||||||
.. _@adler-j: https://github.com/adler-j
|
.. _@adler-j: https://github.com/adler-j
|
||||||
|
@ -45,6 +50,7 @@
|
||||||
.. _#2078: https://github.com/pytest-dev/pytest/issues/2078
|
.. _#2078: https://github.com/pytest-dev/pytest/issues/2078
|
||||||
.. _#2082: https://github.com/pytest-dev/pytest/issues/2082
|
.. _#2082: https://github.com/pytest-dev/pytest/issues/2082
|
||||||
.. _#2103: https://github.com/pytest-dev/pytest/issues/2103
|
.. _#2103: https://github.com/pytest-dev/pytest/issues/2103
|
||||||
|
.. _#2105: https://github.com/pytest-dev/pytest/issues/2105
|
||||||
|
|
||||||
|
|
||||||
3.0.4
|
3.0.4
|
||||||
|
|
|
@ -1149,7 +1149,10 @@ class Config(object):
|
||||||
if self.getoption("override_ini", None):
|
if self.getoption("override_ini", None):
|
||||||
for ini_config_list in self.option.override_ini:
|
for ini_config_list in self.option.override_ini:
|
||||||
for ini_config in ini_config_list:
|
for ini_config in ini_config_list:
|
||||||
(key, user_ini_value) = ini_config.split("=", 1)
|
try:
|
||||||
|
(key, user_ini_value) = ini_config.split("=", 1)
|
||||||
|
except ValueError:
|
||||||
|
raise UsageError("-o/--override-ini expects option=value style.")
|
||||||
if key == name:
|
if key == name:
|
||||||
value = user_ini_value
|
value = user_ini_value
|
||||||
return value
|
return value
|
||||||
|
|
|
@ -23,7 +23,7 @@ def pytest_addoption(parser):
|
||||||
group._addoption(
|
group._addoption(
|
||||||
'-o', '--override-ini', nargs='*', dest="override_ini",
|
'-o', '--override-ini', nargs='*', dest="override_ini",
|
||||||
action="append",
|
action="append",
|
||||||
help="override config option, e.g. `-o xfail_strict=True`.")
|
help="override config option with option=value style, e.g. `-o xfail_strict=True`.")
|
||||||
|
|
||||||
|
|
||||||
@pytest.hookimpl(hookwrapper=True)
|
@pytest.hookimpl(hookwrapper=True)
|
||||||
|
|
|
@ -83,7 +83,7 @@ class TestParseIni:
|
||||||
""")
|
""")
|
||||||
result = testdir.inline_run("--confcutdir=.")
|
result = testdir.inline_run("--confcutdir=.")
|
||||||
assert result.ret == 0
|
assert result.ret == 0
|
||||||
|
|
||||||
class TestConfigCmdlineParsing:
|
class TestConfigCmdlineParsing:
|
||||||
def test_parsing_again_fails(self, testdir):
|
def test_parsing_again_fails(self, testdir):
|
||||||
config = testdir.parseconfig()
|
config = testdir.parseconfig()
|
||||||
|
@ -732,6 +732,14 @@ class TestOverrideIniArgs:
|
||||||
"ini3:True",
|
"ini3:True",
|
||||||
"ini4:False"])
|
"ini4:False"])
|
||||||
|
|
||||||
|
def test_override_ini_usage_error_bad_style(self, testdir):
|
||||||
|
testdir.makeini("""
|
||||||
|
[pytest]
|
||||||
|
xdist_strict=False
|
||||||
|
""")
|
||||||
|
result = testdir.runpytest("--override-ini", 'xdist_strict True', "-s")
|
||||||
|
result.stderr.fnmatch_lines(["*ERROR* *expects option=value*"])
|
||||||
|
|
||||||
def test_with_arg_outside_cwd_without_inifile(self, tmpdir, monkeypatch):
|
def test_with_arg_outside_cwd_without_inifile(self, tmpdir, monkeypatch):
|
||||||
monkeypatch.chdir(str(tmpdir))
|
monkeypatch.chdir(str(tmpdir))
|
||||||
a = tmpdir.mkdir("a")
|
a = tmpdir.mkdir("a")
|
||||||
|
|
Loading…
Reference in New Issue