Ejemplo n.º 1
0
def test_invalid_css_selector_expr(element, expr):
    extractor = CSSExtractor(expr)
    with pytest.raises(ExprError) as catch:
        extractor.extract(element)

    exc = catch.value
    assert exc.extractor is extractor
    assert isinstance(exc.exc, SelectorSyntaxError)
Ejemplo n.º 2
0
def test_invalid_css_selector_expr(element, expr, by):
    extractor = CSSExtractor(expr)
    assert not extractor.built
    with pytest.raises(ExprError) as catch:
        if by == "build":
            extractor.build()
        else:
            extractor.extract(element)

    assert not extractor.built
    exc = catch.value
    assert exc.extractor is extractor
    assert isinstance(exc.exc, SelectorError)
    assert re.match(r"ExprError with .+? raised by .+? extracting", str(exc))