Mercurial > p > roundup > code
diff test/mocknull.py @ 5457:a35d4cc8cd1a
fix MissingValue / MockNull to return False on __bool__ and add a
__contains__ to support 'in' operator correctly
| author | Christof Meerwald <cmeerw@cmeerw.org> |
|---|---|
| date | Mon, 23 Jul 2018 21:45:05 +0100 |
| parents | 3757449e00c4 |
| children | ad8031290639 |
line wrap: on
line diff
--- a/test/mocknull.py Mon Jul 23 21:43:39 2018 +0100 +++ b/test/mocknull.py Mon Jul 23 21:45:05 2018 +0100 @@ -16,9 +16,10 @@ return getattr(self, name) def __getitem__(self, key): return self - def __bool__(self): return 0 + def __bool__(self): return False # Python 2 compatibility: __nonzero__ = __bool__ + def __contains__(self, key): return False def __str__(self): return '' def __repr__(self): return '<MockNull 0x%x>'%id(self) def gettext(self, str): return str
