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