Skip to content

Commit

Permalink
Fix Pytest 5 errors
Browse files Browse the repository at this point in the history
This fixes
"""
pytest.PytestDeprecationWarning: raises(..., 'code(as_a_string)')
is deprecated, use the context manager form or use `exec()` directly.
"""

Fixes: pytest-dev#6
Signed-off-by: Stanislav Levin <slev@altlinux.org>
  • Loading branch information
stanislavlevin committed Aug 8, 2019
1 parent f7f4939 commit 41076a6
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions test_iniconfig.py
Expand Up @@ -150,27 +150,25 @@ def test_iniconfig_from_file(tmpdir):
assert list(config.sections) == ['metadata']
config = IniConfig(path, "[diff]")
assert list(config.sections) == ['diff']
py.test.raises(TypeError, "IniConfig(data=path.read())")
with pytest.raises(TypeError):
IniConfig(data=path.read())


def test_iniconfig_section_first(tmpdir):
excinfo = py.test.raises(ParseError, """
with pytest.raises(ParseError) as excinfo:
IniConfig("x", data='name=1')
""")
assert excinfo.value.msg == "no section header defined"


def test_iniconig_section_duplicate_fails():
excinfo = py.test.raises(ParseError, r"""
with pytest.raises(ParseError) as excinfo:
IniConfig("x", data='[section]\n[section]')
""")
assert 'duplicate section' in str(excinfo.value)


def test_iniconfig_duplicate_key_fails():
excinfo = py.test.raises(ParseError, r"""
with pytest.raises(ParseError) as excinfo:
IniConfig("x", data='[section]\nname = Alice\nname = bob')
""")

assert 'duplicate name' in str(excinfo.value)

Expand Down

0 comments on commit 41076a6

Please sign in to comment.