Exemple #1
0
def _is_error(expr):
    try:
        shorthand.ShorthandParser().parse(expr)
    except shorthand.ShorthandParseError:
        pass
    else:
        raise AssertionError("Expected ShorthandParseError, but no "
                             "exception was raised for expression: %s" % expr)
Exemple #2
0
def _is_error(expr):
    try:
        shorthand.ShorthandParser().parse(expr)
    except shorthand.ShorthandParseError:
        pass
    except Exception as e:
        raise AssertionError(
            "Expected ShorthandParseError, but received unexpected "
            "exception instead (%s): %s" % (e.__class__, e))
    else:
        raise AssertionError("Expected ShorthandParseError, but no "
                             "exception was raised for expression: %s" % expr)
Exemple #3
0
 def __init__(self):
     self._parser = shorthand.ShorthandParser()
     self._visitor = shorthand.BackCompatVisitor()
Exemple #4
0
def _can_parse(data, expected):
    actual = shorthand.ShorthandParser().parse(data)
    assert_equal(actual, expected)
Exemple #5
0
def test_parse(data, expected):
    actual = shorthand.ShorthandParser().parse(data)
    assert actual == expected
Exemple #6
0
def test_error_parsing(expr):
    with pytest.raises(shorthand.ShorthandParseError):
        shorthand.ShorthandParser().parse(expr)