Example #1
0
 def test_match_basic_bool(self):
     match = pattern((bool, lambda i: False))
     result = match(True)
     assert not result
Example #2
0
 def test_match_basic_float(self):
     match = pattern((float, lambda i: i + 1))
     result = match(0.0)
     assert result == 1.0
Example #3
0
 def test_match_basic_int(self):
     match = pattern((int, lambda i: i + 1))
     result = match(0)
     assert result == 1
Example #4
0
 def test_match_basic_str(self):
     match = pattern((str, lambda i: "goodbye"))
     result = match("Hello World")
     assert result == "goodbye"
Example #5
0
 def test_does_not_match_pattern(self):
     match = pattern((int, lambda i: i + 1))
     result = match("Hello World")
     assert result is None
Example #6
0
 def test_no_patterns_pattern(self):
     match = pattern()
     result = match("Hello World")
     assert result is None