[4.6] Improve output when parsing an ini configuration fails (#… (#5652)
[4.6] Improve output when parsing an ini configuration fails (#5650)
This commit is contained in:
commit
829941a061
|
@ -13,6 +13,10 @@ env:
|
||||||
global:
|
global:
|
||||||
- PYTEST_ADDOPTS=-vv
|
- PYTEST_ADDOPTS=-vv
|
||||||
|
|
||||||
|
# setuptools-scm needs all tags in order to obtain a proper version
|
||||||
|
git:
|
||||||
|
depth: false
|
||||||
|
|
||||||
install:
|
install:
|
||||||
- python -m pip install --upgrade --pre tox
|
- python -m pip install --upgrade --pre tox
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Improved output when parsing an ini configuration file fails.
|
|
@ -33,7 +33,11 @@ def getcfg(args, config=None):
|
||||||
for inibasename in inibasenames:
|
for inibasename in inibasenames:
|
||||||
p = base.join(inibasename)
|
p = base.join(inibasename)
|
||||||
if exists(p):
|
if exists(p):
|
||||||
iniconfig = py.iniconfig.IniConfig(p)
|
try:
|
||||||
|
iniconfig = py.iniconfig.IniConfig(p)
|
||||||
|
except py.iniconfig.ParseError as exc:
|
||||||
|
raise UsageError(str(exc))
|
||||||
|
|
||||||
if (
|
if (
|
||||||
inibasename == "setup.cfg"
|
inibasename == "setup.cfg"
|
||||||
and "tool:pytest" in iniconfig.sections
|
and "tool:pytest" in iniconfig.sections
|
||||||
|
|
|
@ -131,6 +131,12 @@ class TestParseIni(object):
|
||||||
config = testdir.parseconfigure(sub)
|
config = testdir.parseconfigure(sub)
|
||||||
assert config.getini("minversion") == "2.0"
|
assert config.getini("minversion") == "2.0"
|
||||||
|
|
||||||
|
def test_ini_parse_error(self, testdir):
|
||||||
|
testdir.tmpdir.join("pytest.ini").write("addopts = -x")
|
||||||
|
result = testdir.runpytest()
|
||||||
|
assert result.ret != 0
|
||||||
|
result.stderr.fnmatch_lines(["ERROR: *pytest.ini:1: no section header defined"])
|
||||||
|
|
||||||
@pytest.mark.xfail(reason="probably not needed")
|
@pytest.mark.xfail(reason="probably not needed")
|
||||||
def test_confcutdir(self, testdir):
|
def test_confcutdir(self, testdir):
|
||||||
sub = testdir.mkdir("sub")
|
sub = testdir.mkdir("sub")
|
||||||
|
|
Loading…
Reference in New Issue