Skip to content

Commit

Permalink
Improve error message when file not found (#44)
Browse files Browse the repository at this point in the history
Solve #41
  • Loading branch information
perolavsvendsen authored Nov 13, 2022
1 parent bdf8f45 commit 744e884
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 0 additions & 4 deletions src/fmu/config/utilities.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""Module with some simple functions, e.g. for parsing for YAML into RMS
"""
import os

# for ordered dicts!
from fmu.config import oyaml as yaml
Expand All @@ -24,9 +23,6 @@ def yaml_load(filename, safe=True, tool=None):
"""

if not os.path.isfile(filename):
raise IOError("File {} cannot be read".format(filename))

with open(filename, "r") as stream:
if safe:
cfg = yaml.safe_load(stream)
Expand Down
5 changes: 5 additions & 0 deletions tests/test_utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
import fmu.config as config
from fmu.config import utilities as utils

import pytest

# import fmu.config.fmuconfigrunner as fmurun

fmux = config.etc.Interaction()
Expand All @@ -20,3 +22,6 @@ def test_basic_tools():
cfg = utils.yaml_load(REEK)

assert cfg["global"]["name"] == "Reek"

with pytest.raises(FileNotFoundError):
utils.yaml_load("not_a_file.xyz")

0 comments on commit 744e884

Please sign in to comment.