Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 6
0
 def assert_parse_expression_equals_expression_repr(text, expected):
     parser = TagExpressionParser()
     expression = parser.parse(text)
     expression_text = repr(expression)
     assert expected == expression_text
Ejemplo n.º 7
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)
Ejemplo n.º 8
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)
Ejemplo n.º 9
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())
Ejemplo n.º 10
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)
Ejemplo n.º 11
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)
Ejemplo n.º 12
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)
Ejemplo n.º 13
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)
Ejemplo n.º 14
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())
Ejemplo n.º 15
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)
Ejemplo n.º 16
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)