mirror of https://github.com/mahmoud/boltons.git
setting Sentinel __nonzero__/__bool__ alias and also adding a test for sentinel falsiness
This commit is contained in:
parent
ef8a5ca025
commit
2ff30aefe0
|
@ -53,8 +53,11 @@ def make_sentinel(name='_MISSING', var_name=None):
|
|||
def __reduce__(self):
|
||||
return self.var_name
|
||||
|
||||
def __len__(self):
|
||||
return 0
|
||||
def __nonzero__(self):
|
||||
return False
|
||||
|
||||
__bool__ = __nonzero__
|
||||
|
||||
return Sentinel()
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
|
||||
from boltons.typeutils import make_sentinel
|
||||
|
||||
|
||||
def test_sentinel_falsiness():
|
||||
not_set = make_sentinel('not_set')
|
||||
assert not not_set
|
Loading…
Reference in New Issue