Boolean Types¶
IsTrueLike ¶
Bases: DirtyEquals[bool]
Check if the value is True like. IsTrueLike
allows comparison to anything and effectively uses just
return bool(other)
.
Example of basic usage:
IsTrueLike
from dirty_equals import IsTrueLike
assert True == IsTrueLike
assert 1 == IsTrueLike
assert 'true' == IsTrueLike
assert 'foobar' == IsTrueLike # any non-empty string is "True"
assert '' != IsTrueLike
assert [1] == IsTrueLike
assert {} != IsTrueLike
assert None != IsTrueLike
Parameters:
IsFalseLike ¶
IsFalseLike(*, allow_strings: bool = False)
Bases: DirtyEquals[bool]
Check if the value is False like. IsFalseLike
allows comparison to anything and effectively uses
return not bool(other)
(with string checks if allow_strings=True
is set).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
allow_strings |
bool
|
if |
False
|
Example of basic usage:
IsFalseLike
from dirty_equals import IsFalseLike
assert False == IsFalseLike
assert 0 == IsFalseLike
assert 'false' == IsFalseLike(allow_strings=True)
assert '0' == IsFalseLike(allow_strings=True)
assert 'foobar' != IsFalseLike(allow_strings=True)
assert 'false' != IsFalseLike
assert 'True' != IsFalseLike(allow_strings=True)
assert [1] != IsFalseLike
assert {} == IsFalseLike
assert None == IsFalseLike
assert '' == IsFalseLike(allow_strings=True)
assert '' == IsFalseLike