Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 3
0
 def __init__(self):
     self._parser = shorthand.ShorthandParser()
     self._visitor = shorthand.BackCompatVisitor()
Ejemplo n.º 4
0
def _can_parse(data, expected):
    actual = shorthand.ShorthandParser().parse(data)
    assert_equal(actual, expected)
Ejemplo n.º 5
0
def test_parse(data, expected):
    actual = shorthand.ShorthandParser().parse(data)
    assert actual == expected
Ejemplo n.º 6
0
def test_error_parsing(expr):
    with pytest.raises(shorthand.ShorthandParseError):
        shorthand.ShorthandParser().parse(expr)