Add test for sourcing config with invalid source

This commit is contained in:
George Edward Bulmer 2018-02-12 14:19:18 +00:00
parent b59a7cdcc0
commit 5b718446b6

View File

@ -309,6 +309,18 @@ class TestSource:
" While setting 'foo': No option 'foo'") " While setting 'foo': No option 'foo'")
assert str(excinfo.value) == expected assert str(excinfo.value) == expected
def test_invalid_source(self, commands, config_tmpdir):
pyfile = config_tmpdir / 'config.py'
pyfile.write_text('1/0', encoding='utf-8')
with pytest.raises(cmdexc.CommandError) as excinfo:
commands.config_source()
expected = ("Errors occurred while reading config.py:\n"
" Unhandled exception - ZeroDivisionError:"
" division by zero ")
assert str(excinfo.value) == expected
class TestEdit: class TestEdit: