Handle OSError in :config-write-py
This commit is contained in:
parent
8fb03208e7
commit
2b063f577e
@ -289,4 +289,7 @@ class ConfigCommands:
|
|||||||
|
|
||||||
writer = configfiles.ConfigPyWriter(options, bindings,
|
writer = configfiles.ConfigPyWriter(options, bindings,
|
||||||
commented=commented)
|
commented=commented)
|
||||||
writer.write(filename)
|
try:
|
||||||
|
writer.write(filename)
|
||||||
|
except OSError as e:
|
||||||
|
raise cmdexc.CommandError(str(e))
|
||||||
|
@ -413,6 +413,11 @@ class TestWritePy:
|
|||||||
lines = confpy.read_text('utf-8').splitlines()
|
lines = confpy.read_text('utf-8').splitlines()
|
||||||
assert '# Autogenerated config.py' in lines
|
assert '# Autogenerated config.py' in lines
|
||||||
|
|
||||||
|
def test_oserror(self, commands, tmpdir):
|
||||||
|
"""Test writing to a directory which does not exist."""
|
||||||
|
with pytest.raises(cmdexc.CommandError):
|
||||||
|
commands.config_write_py(str(tmpdir / 'foo' / 'config.py'))
|
||||||
|
|
||||||
|
|
||||||
class TestBind:
|
class TestBind:
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user