Improve output when parsing an ini configuration fails (#5650)
Improve output when parsing an ini configuration fails
This commit is contained in:
commit
52ad5a1591
|
@ -0,0 +1 @@
|
|||
Improved output when parsing an ini configuration file fails.
|
|
@ -32,7 +32,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
|
||||
|
|
|
@ -122,6 +122,12 @@ class TestParseIni:
|
|||
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