File tree Expand file tree Collapse file tree 2 files changed +5
-0
lines changed Expand file tree Collapse file tree 2 files changed +5
-0
lines changed Original file line number Diff line number Diff line change @@ -40,6 +40,9 @@ def __init__(self, env_file_path=None):
4040 if self ._path and self ._path .exists ():
4141 self ._cache .update (read_json (self ._path ))
4242
43+ def __contains__ (self , key ):
44+ return key in self ._cache
45+
4346 def __getitem__ (self , key ):
4447 return self ._cache .get (key )
4548
Original file line number Diff line number Diff line change @@ -92,6 +92,7 @@ def test_JsonFileCache(monkeypatch):
9292 cache = JsonFileCache ("INFO_FILE" )
9393
9494 assert cache ._path .exists ()
95+ assert "key" in cache
9596 assert cache .get ("key" ) == "value"
9697 assert cache ["key" ] == "value"
9798 assert cache .get ("other" ) is None
@@ -108,3 +109,4 @@ def test_JsonFileCache_no_file():
108109 assert cache ._cache == {}
109110 assert cache ._path is None
110111 assert cache .get ("key" ) is None
112+ assert "key" not in cache
You can’t perform that action at this time.
0 commit comments