Skip to content

Commit

Permalink
Add support for the new csselect API used in :has().
Browse files Browse the repository at this point in the history
  • Loading branch information
wRAR committed Oct 27, 2022
1 parent e5e6a67 commit 086f0a3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 2 additions & 2 deletions parsel/csstranslator.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ def __str__(self):

return path

def join(self, combiner, other):
super().join(combiner, other)
def join(self, combiner, other, *args, **kwargs):
super().join(combiner, other, *args, **kwargs)
self.textnode = other.textnode
self.attribute = other.attribute
return self
Expand Down
10 changes: 10 additions & 0 deletions tests/test_selector_csstranslator.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
Selector tests for cssselect backend
"""
import unittest

import cssselect
import pytest
from pkg_resources import parse_version

from parsel.csstranslator import GenericTranslator, HTMLTranslator
from parsel import Selector
from cssselect.parser import SelectorSyntaxError
Expand Down Expand Up @@ -196,3 +201,8 @@ def test_nested_selector(self):
self.sel.css("div").css("area:last-child").extract(),
['<area shape="default" id="area-nohref">'],
)

@pytest.mark.xfail(parse_version(cssselect.__version__) < parse_version("1.2.0"),
reason="Support added in cssselect 1.2.0")
def test_pseudoclass_has(self):
self.assertEqual(self.x("p:has(b)::text"), ["lorem ipsum text"])

0 comments on commit 086f0a3

Please sign in to comment.