Beispiel #1
0
    def assert_parse_with_error_contains_message(text, error_message):
        parser = TagExpressionParser()
        with pytest.raises(TagExpressionError) as exc_info:
            parser.parse(text)

        exc_text = exc_info.exconly()
        print(exc_text)
        assert error_message in exc_text
Beispiel #2
0
    def assert_parse_with_error_contains_message(text, error_message):
        parser = TagExpressionParser()
        with pytest.raises(TagExpressionError) as exc_info:
            parser.parse(text)

        exc_text = exc_info.exconly()
        print(exc_text)
        assert error_message in exc_text
Beispiel #3
0
 def test_not_not_expression_sameas_expression(self, tag_expression_text, expected, tags, case):
     not2_tag_expression_text = "not not "+ tag_expression_text
     tag_expression1 = TagExpressionParser.parse(tag_expression_text)
     tag_expression2 = TagExpressionParser.parse(not2_tag_expression_text)
     value1 = tag_expression1.evaluate(tags)
     value2 = tag_expression2.evaluate(tags)
     assert value1 == value2
     assert expected == value1
Beispiel #4
0
 def test_not_not_expression_sameas_expression(self, tag_expression_text,
                                               expected, tags, case):
     not2_tag_expression_text = "not not " + tag_expression_text
     tag_expression1 = TagExpressionParser.parse(tag_expression_text)
     tag_expression2 = TagExpressionParser.parse(not2_tag_expression_text)
     value1 = tag_expression1.evaluate(tags)
     value2 = tag_expression2.evaluate(tags)
     assert value1 == value2
     assert expected == value1
Beispiel #5
0
 def assert_parse_expression_equals_expression_repr(text, expected):
     parser = TagExpressionParser()
     expression = parser.parse(text)
     expression_text = repr(expression)
     assert expected == expression_text
Beispiel #6
0
 def test_select_token(self, text, expected):
     token = TagExpressionParser.select_token(text)
     assert token is expected
Beispiel #7
0
 def assert_parse_expression_equals_expression_repr(text, expected):
     parser = TagExpressionParser()
     expression = parser.parse(text)
     expression_text = repr(expression)
     assert expected == expression_text
Beispiel #8
0
 def test_or_operation(self, tag_expression_text, expected, tags, case):
     tag_expression = TagExpressionParser.parse(tag_expression_text)
     assert expected == tag_expression.evaluate(tags)
Beispiel #9
0
 def test_fails_when_only_operators_are_used(self, tag_part):
     with pytest.raises(TagExpressionError):
         # -- EXAMPLE: text = "or or"
         text = "{part} {part}".format(part=tag_part)
         TagExpressionParser.parse(text)
Beispiel #10
0
 def test_not_matcher(self, tag_expression_text, expected, tags, case):
     tag_expression = TagExpressionParser.parse(tag_expression_text)
     assert expected == tag_expression.evaluate(tags)
Beispiel #11
0
 def test_empty_expression_is_true(self, tag_expression_text, expected, tags, case):
     tag_expression = TagExpressionParser.parse(tag_expression_text)
     assert expected == tag_expression.evaluate(tags)
Beispiel #12
0
 def test_not_matcher(self, tag_expression_text, expected, tags, case):
     tag_expression = TagExpressionParser.parse(tag_expression_text)
     assert expected == tag_expression.evaluate(tags)
Beispiel #13
0
 def test_or_operation(self, tag_expression_text, expected, tags, case):
     tag_expression = TagExpressionParser.parse(tag_expression_text)
     assert expected == tag_expression.evaluate(tags)
Beispiel #14
0
 def test_fails_when_only_operators_are_used(self, tag_part):
     with pytest.raises(TagExpressionError):
         # -- EXAMPLE: text = "or or"
         text = "{part} {part}".format(part=tag_part)
         TagExpressionParser.parse(text)
Beispiel #15
0
 def test_complex_example(self):
     tag_expression_text = "not @a or @b and not @c or not @d or @e and @f"
     tag_expression = TagExpressionParser.parse(tag_expression_text)
     assert False == tag_expression.evaluate("@a @c @d".split())
Beispiel #16
0
 def test_empty_expression_is_true(self, tag_expression_text, expected,
                                   tags, case):
     tag_expression = TagExpressionParser.parse(tag_expression_text)
     assert expected == tag_expression.evaluate(tags)
Beispiel #17
0
 def test_select_token(self, text, expected):
     token = TagExpressionParser.select_token(text)
     assert token is expected
Beispiel #18
0
 def test_complex_example(self):
     tag_expression_text = "not @a or @b and not @c or not @d or @e and @f"
     tag_expression = TagExpressionParser.parse(tag_expression_text)
     assert False == tag_expression.evaluate("@a @c @d".split())