From 086f0a3a7e5104b246063ae63aa9e72d60078007 Mon Sep 17 00:00:00 2001 From: Andrey Rakhmatullin Date: Thu, 27 Oct 2022 15:52:28 +0600 Subject: [PATCH] Add support for the new csselect API used in :has(). --- parsel/csstranslator.py | 4 ++-- tests/test_selector_csstranslator.py | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/parsel/csstranslator.py b/parsel/csstranslator.py index 3bc359dc..c240e6ac 100644 --- a/parsel/csstranslator.py +++ b/parsel/csstranslator.py @@ -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 diff --git a/tests/test_selector_csstranslator.py b/tests/test_selector_csstranslator.py index c720006f..9567a07b 100644 --- a/tests/test_selector_csstranslator.py +++ b/tests/test_selector_csstranslator.py @@ -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 @@ -196,3 +201,8 @@ def test_nested_selector(self): self.sel.css("div").css("area:last-child").extract(), [''], ) + + @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"])