File tree Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -58,7 +58,9 @@ def __init__(
58
58
self .environ = environ
59
59
self .env_prefix = env_prefix
60
60
self .file_values : typing .Dict [str , str ] = {}
61
- if env_file is not None and os .path .isfile (env_file ):
61
+ if env_file is not None :
62
+ if not os .path .isfile (env_file ):
63
+ raise FileNotFoundError (f"Config file '{ env_file } ' not found." )
62
64
self .file_values = self ._read_file (env_file )
63
65
64
66
@typing .overload
Original file line number Diff line number Diff line change @@ -104,6 +104,13 @@ def cast_to_int(v) -> int:
104
104
config .get ("BOOL_AS_INT" , cast = bool )
105
105
106
106
107
+ def test_missing_env_file_raises (tmpdir ):
108
+ path = os .path .join (tmpdir , ".env" )
109
+
110
+ with pytest .raises (FileNotFoundError , match = f"Config file '{ path } ' not found." ):
111
+ Config (path )
112
+
113
+
107
114
def test_environ ():
108
115
environ = Environ ()
109
116
You can’t perform that action at this time.
0 commit comments