comparison 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
comparison
equal deleted inserted replaced
5456:0fb04e717de0 5457:a35d4cc8cd1a
14 # client.db.config.TRACKER_WEB = 'BASE/' 14 # client.db.config.TRACKER_WEB = 'BASE/'
15 self.__dict__[name] = MockNull() 15 self.__dict__[name] = MockNull()
16 return getattr(self, name) 16 return getattr(self, name)
17 17
18 def __getitem__(self, key): return self 18 def __getitem__(self, key): return self
19 def __bool__(self): return 0 19 def __bool__(self): return False
20 # Python 2 compatibility: 20 # Python 2 compatibility:
21 __nonzero__ = __bool__ 21 __nonzero__ = __bool__
22 def __contains__(self, key): return False
22 def __str__(self): return '' 23 def __str__(self): return ''
23 def __repr__(self): return '<MockNull 0x%x>'%id(self) 24 def __repr__(self): return '<MockNull 0x%x>'%id(self)
24 def gettext(self, str): return str 25 def gettext(self, str): return str
25 _ = gettext 26 _ = gettext

Roundup Issue Tracker: http://roundup-tracker.org/