Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_attr_function_exception(self):
cases = [
('::attr(12)', ExpressionError),
('::attr(34test)', ExpressionError),
('::attr(@href)', SelectorSyntaxError),
]
for css, exc in cases:
self.assertRaises(exc, self.c2x, css)
def test_attr_function_exception(self):
cases = [
('::attr(12)', ExpressionError),
('::attr(34test)', ExpressionError),
('::attr(@href)', SelectorSyntaxError),
]
for css, exc in cases:
self.assertRaises(exc, self.c2x, css)
def selector_content_find(document, selector):
"""
Provided a selector, returns the relevant content from the document
"""
content = ''
try:
page = pq(document.rendered_html)
except ValueError:
# pass errors during construction
pass
try:
content = page.find(selector).text()
except SelectorSyntaxError:
# pass errors during find/select
pass
return content