Skip to content

Commit

Permalink
feat(Executables): support collection-style membership test (#131)
Browse files Browse the repository at this point in the history
  • Loading branch information
wpbonelli authored Dec 18, 2023
1 parent 2c68491 commit 3129417
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions autotest/test_executables.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,6 @@ def test_access(exes):
# .get() works too
assert exes.get("not a target") is None
assert exes.get("not a target", exes["pytest"]) == exes["pytest"]
# membership test
assert "not a target" not in exes
assert "pytest" in exes
3 changes: 3 additions & 0 deletions modflow_devtools/executables.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ class Executables(SimpleNamespace):
def __init__(self, **kwargs):
super().__init__(**kwargs)

def __contains__(self, item):
return item in self.__dict__

def __setitem__(self, key, item):
self.__dict__[key] = item

Expand Down

0 comments on commit 3129417

Please sign in to comment.