Skip to content

Commit

Permalink
utils: Make Mimic support indexing
Browse files Browse the repository at this point in the history
  • Loading branch information
jayvdb committed Jun 10, 2020
1 parent 06d26d1 commit 61da050
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions siteprefs/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ def value(self):

assert M(4)() == 4
assert str(M('www')) == 'www'
assert str(M('abc')[1]) == 'b'
assert len(M('some')) == 4
assert int(M(4)) == 4
assert float(M(4.2)) == 4.2
Expand Down
3 changes: 3 additions & 0 deletions siteprefs/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ def __len__(self):
def __contains__(self, item):
return self.value.__contains__(item)

def __getitem__(self, item):
return self.value[item]

def __sub__(self, other):
return self.value.__sub__(other)

Expand Down

0 comments on commit 61da050

Please sign in to comment.