diff --git a/_delb/xpath/__init__.py b/_delb/xpath/__init__.py index efb1804d..b7cffbf3 100644 --- a/_delb/xpath/__init__.py +++ b/_delb/xpath/__init__.py @@ -167,7 +167,7 @@ def size(self) -> int: # TODO make cachesize configurable via environment variable? @lru_cache(maxsize=64) def _css_to_xpath(expression: str) -> str: - return _css_translator.css_to_xpath(expression, prefix="descendant-or-self::") + return _css_translator.css_to_xpath(expression, prefix="descendant::") def evaluate( diff --git a/docs/conf.py b/docs/conf.py index a07204dc..919b0648 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -276,7 +276,7 @@ def predicate(self, name, attr, meta): and meta.get("category") is None and is_really_public(name) # deprecation wrapper from 961b8b822ed9d8e33a4f9a63b71e64f30188cc67 - and not attr.__qualname__.startswith("_better") + and not getattr(attr, "__qualname__", "").startswith("_better") ) diff --git a/docs/rtd-dependencies.txt b/docs/rtd-dependencies.txt index e9cc7b0b..5c58325a 100644 --- a/docs/rtd-dependencies.txt +++ b/docs/rtd-dependencies.txt @@ -1,5 +1,5 @@ -autoclasstoc>=1.1.1 -requests -sphinx>=3 +autoclasstoc @ git+https://github.com/kalekundert/autoclasstoc.git@ba868daf4fecc72bd1a8957c565760d4c41eb71a +httpx[http2] +sphinx sphinxcontrib-fulltoc sphinx-readable-theme diff --git a/pyproject.toml b/pyproject.toml index 481fc3f5..1cdeb427 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -107,9 +107,10 @@ dependencies = ["cff-from-621"] skip-install = true [tool.hatch.envs.docs] -python = "3.10" # TODO drop when a successor of 1.5.2 is released, also mind .github/workflows/quality-checks.yml + # TODO drop when a successor of 1.5.2 is released, also mind .github/workflows/quality-checks.yml and docs/rtd-dependencies.txt +python = "3.10" dependencies = [ - # TODO switch to PyPI when this is fixed: + # TODO switch to PyPI when this is fixed: https://github.com/kalekundert/autoclasstoc/issues/33 "autoclasstoc @ git+https://github.com/kalekundert/autoclasstoc.git@ba868daf4fecc72bd1a8957c565760d4c41eb71a", "sphinxcontrib-fulltoc", "sphinx-readable-theme" diff --git a/tests/test_attributes.py b/tests/test_attributes.py index ab8b3beb..4fecc31d 100644 --- a/tests/test_attributes.py +++ b/tests/test_attributes.py @@ -63,7 +63,7 @@ def test_attribute_object(): def test_delete_namespaced_attribute(): root = Document('').root - node = root.css_select("root > node")[0] + node = root.css_select("node").first assert len(node.attributes) == 2 del node.attributes["ns":"a"] assert len(node.attributes) == 1 diff --git a/tests/test_css_select.py b/tests/test_css_select.py index 57e2f4c2..f4dfe5fc 100644 --- a/tests/test_css_select.py +++ b/tests/test_css_select.py @@ -1,4 +1,7 @@ +import pytest + from delb import Document +from _delb.xpath import _css_to_xpath def test_css_considers_xml_namespace(files_path): @@ -21,8 +24,13 @@ def test_css_select_or(files_path): assert {x.local_name for x in result} == {"author", "title"} +@pytest.mark.parametrize(("_in", "out"), (("metadata", "descendant::metadata"),)) +def test_css_to_xpath(_in, out): + assert _css_to_xpath(_in) == out + + def test_quotes_in_css_selector(): - document = Document('') + document = Document('') assert document.css_select('a[href^="https://super.test/"]').size == 1 assert document.css_select('a[href|="https://super.test/123"]').size == 1 assert document.css_select('a[href*="super"]').size == 1 diff --git a/tests/test_transform.py b/tests/test_transform.py index d3be0f99..b362fc9f 100644 --- a/tests/test_transform.py +++ b/tests/test_transform.py @@ -137,14 +137,15 @@ def test_transformation_sequence_sequence(): """, parser_options=ParserOptions(collapse_whitespace=True), ) - root = Document("