Skip to content
Snippets Groups Projects
Commit 04d55888 authored by Piotr Maślanka's avatar Piotr Maślanka
Browse files

added `Predicate.false`

parent afa37f54
No related branches found
No related tags found
No related merge requests found
......@@ -2,3 +2,4 @@
* added `dont_raise` to `Condition`
* added `ImpossibleError`
* added `Predicate.false`
__version__ = '2.14.26a3'
__version__ = '2.14.26a4'
......@@ -86,6 +86,8 @@ class PredicateClass:
str = make_operation_single_arg(str, 'Call str() on predicate')
int = make_operation_single_arg(int, 'Call int() on predicate')
float = make_operation_single_arg(float, 'Call float() on predicate')
false = make_operation_single_arg(lambda y: not y, 'Return a predicate checking whether '
'value is False')
def __call__(self, *args) -> bool:
if len(args) == 0:
......
......@@ -50,6 +50,9 @@ class TestPredicates(unittest.TestCase):
def test_bool_str(self):
p = x.int().str()
self.assertEqual(p(True), '1')
p = x.false()
self.assertTrue(p(False))
self.assertFalse(p(True))
def test_upper(self):
p = x.upper()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment