diff --git a/flask_annex/file.py b/flask_annex/file.py index 353f704..f3b828f 100644 --- a/flask_annex/file.py +++ b/flask_annex/file.py @@ -13,6 +13,9 @@ class FileAnnex(AnnexBase): def __init__(self, root_path): + if not os.path.exists(root_path): + raise IOError("root path {} does not exist".format(root_path)) + self._root_path = root_path def _get_filename(self, key): diff --git a/tests/test_file.py b/tests/test_file.py index e9e737a..0dd5d44 100644 --- a/tests/test_file.py +++ b/tests/test_file.py @@ -11,7 +11,7 @@ @pytest.fixture def file_annex_path(tmpdir): - return tmpdir.join('annex').strpath + return tmpdir.join('annex').mkdir().strpath # ----------------------------------------------------------------------------- @@ -41,3 +41,11 @@ def annex_base(self, monkeypatch, file_annex_path): monkeypatch.setenv('FLASK_ANNEX_FILE_ROOT_PATH', file_annex_path) return Annex.from_env('FLASK_ANNEX') + + +# ----------------------------------------------------------------------------- + + +def test_error_nonexistent_root_path(): + with pytest.raises(IOError): + Annex('file', root_path='/dummy')