Skip to content

Commit

Permalink
Allow empty strings in asserts (#130)
Browse files Browse the repository at this point in the history
  • Loading branch information
wRAR committed Oct 25, 2022
1 parent 02eff50 commit 0d5e380
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions cssselect/xpath.py
Expand Up @@ -673,14 +673,14 @@ def xpath_attrib_exists(self, xpath: XPathExpr, name: str, value: Optional[str])
return xpath

def xpath_attrib_equals(self, xpath: XPathExpr, name: str, value: Optional[str]) -> XPathExpr:
assert value
assert value is not None
xpath.add_condition("%s = %s" % (name, self.xpath_literal(value)))
return xpath

def xpath_attrib_different(
self, xpath: XPathExpr, name: str, value: Optional[str]
) -> XPathExpr:
assert value
assert value is not None
# FIXME: this seems like a weird hack...
if value:
xpath.add_condition("not(%s) or %s != %s" % (name, name, self.xpath_literal(value)))
Expand All @@ -703,7 +703,7 @@ def xpath_attrib_includes(
def xpath_attrib_dashmatch(
self, xpath: XPathExpr, name: str, value: Optional[str]
) -> XPathExpr:
assert value
assert value is not None
# Weird, but true...
xpath.add_condition(
"%s and (%s = %s or starts-with(%s, %s))"
Expand Down

0 comments on commit 0d5e380

Please sign in to comment.