[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:
|
||||
- PYTEST_ADDOPTS=-vv
|
||||
|
||||
# setuptools-scm needs all tags in order to obtain a proper version
|
||||
git:
|
||||
depth: false
|
||||
|
||||
install:
|
||||
- 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:
|
||||
p = base.join(inibasename)
|
||||
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 (
|
||||
inibasename == "setup.cfg"
|
||||
and "tool:pytest" in iniconfig.sections
|
||||
|
|
|
@ -131,6 +131,12 @@ class TestParseIni(object):
|
|||
config = testdir.parseconfigure(sub)
|
||||
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")
|
||||
def test_confcutdir(self, testdir):
|
||||
sub = testdir.mkdir("sub")
|
||||
|
|
Loading…
Reference in New Issue