Files
gentoo/dev-python/pyquery/files/pyquery-2.0.1-newer-pythons.patch
Sam James c0751238b9 dev-python/pyquery: enable py3.15, fix tests
Also, modernise the ebuild.

Closes: https://bugs.gentoo.org/969982
Signed-off-by: Sam James <sam@gentoo.org>
2026-07-03 20:03:52 +01:00

182 lines
6.3 KiB
Diff
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
https://github.com/gawel/pyquery/commit/ce3ad507fd89c581bdd7aa086e96590e1f124277
From ce3ad507fd89c581bdd7aa086e96590e1f124277 Mon Sep 17 00:00:00 2001
From: Gael Pasgrimaud <gael@gawel.org>
Date: Wed, 18 Feb 2026 21:06:19 +0100
Subject: [PATCH] drop support for py3.9/3.10
---
pyquery/pyquery.py | 8 +++++---
setup.py | 3 +--
tests/test_pyquery.py | 23 +++++++++++++----------
tox.ini | 6 +++---
6 files changed, 27 insertions(+), 23 deletions(-)
diff --git a/pyquery/pyquery.py b/pyquery/pyquery.py
index 5b05681..53aeaac 100644
--- a/pyquery/pyquery.py
+++ b/pyquery/pyquery.py
@@ -1004,7 +1004,7 @@ def val(self, value=no_default):
def _get_value(tag):
# <textarea>
if tag.tag == 'textarea':
- return self._copy(tag).html()
+ return self._copy(tag).html(escape=False)
# <select>
elif tag.tag == 'select':
if 'multiple' in tag.attrib:
@@ -1097,7 +1097,9 @@ def html(self, value=no_default, **kwargs):
return None
tag = self[0]
children = tag.getchildren()
- html = escape(tag.text or '', quote=False)
+ html = tag.text or ''
+ if kwargs.pop('escape', True):
+ html = escape(html, quote=False)
if not children:
return html
if 'encoding' not in kwargs:
@@ -1188,7 +1190,7 @@ def text(self, value=no_default, **kwargs):
if not self:
return ''
return ' '.join(
- self._copy(tag).html() if tag.tag == 'textarea' else
+ self._copy(tag).html(escape=False) if tag.tag == 'textarea' else
extract_text(tag, **kwargs) for tag in self
)
diff --git a/setup.py b/setup.py
index 9c54b0e..f32f066 100644
--- a/setup.py
+++ b/setup.py
@@ -49,10 +49,9 @@ def read(*names):
"Intended Audience :: Developers",
"Development Status :: 5 - Production/Stable",
"Programming Language :: Python :: 3",
- "Programming Language :: Python :: 3.9",
- "Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
+ "Programming Language :: Python :: 3.13",
],
keywords='jquery html xml scraping',
author='Olivier Lauzanne',
diff --git a/tests/test_pyquery.py b/tests/test_pyquery.py
index df6e3b8..b8ee3c8 100644
--- a/tests/test_pyquery.py
+++ b/tests/test_pyquery.py
@@ -11,6 +11,8 @@
from webtest.debugapp import debug_app
from unittest import TestCase
+import pytest
+
sys.path.insert(0, os.path.dirname(os.path.dirname(__file__)))
@@ -534,10 +536,9 @@ def test_val_for_textarea(self):
self.assertEqual(d('#textarea-multi').val(), multi_expected)
self.assertEqual(d('#textarea-multi').text(), multi_expected)
multi_new = '''Bacon\n<b>Eggs</b>\nSpam'''
- multi_new_expected = '''Bacon\n&lt;b&gt;Eggs&lt;/b&gt;\nSpam'''
d('#textarea-multi').val(multi_new)
- self.assertEqual(d('#textarea-multi').val(), multi_new_expected)
- self.assertEqual(d('#textarea-multi').text(), multi_new_expected)
+ self.assertEqual(d('#textarea-multi').val(), multi_new)
+ self.assertEqual(d('#textarea-multi').text(), multi_new)
def test_val_for_select(self):
d = pq(self.html4)
@@ -784,6 +785,7 @@ def test_make_link(self):
'http://example.com/path_info')
+@pytest.mark.skipif(os.name == 'nt', reason='fail on windows')
class TestHTMLParser(TestCase):
xml = "<div>I'm valid XML</div>"
html = '''<div class="portlet">
@@ -802,7 +804,7 @@ def test_replaceWith(self):
expected = '''<div class="portlet">
<a href="/toto">TestimageMy link text</a>
<a href="/toto2">imageMy link text 2</a>
- Behind you, a three-headed HTML&amp;dash;Entity!
+ Behind you, a three-headed HTMLEntity!
</div>'''
d = pq(self.html)
d('img').replace_with('image')
@@ -813,7 +815,7 @@ def test_replaceWith_with_function(self):
expected = '''<div class="portlet">
TestimageMy link text
imageMy link text 2
- Behind you, a three-headed HTML&amp;dash;Entity!
+ Behind you, a three-headed HTMLEntity!
</div>'''
d = pq(self.html)
d('a').replace_with(lambda i, e: pq(e).html())
@@ -899,14 +901,14 @@ def test_get(self):
d = pq(url=self.application_url, data={'q': 'foo'},
method='get')
print(d)
- self.assertIn('REQUEST_METHOD: GET', d('p').text())
- self.assertIn('q=foo', d('p').text())
+ self.assertIn('REQUEST_METHOD: GET', d.text())
+ self.assertIn('q=foo', d.text())
def test_post(self):
d = pq(url=self.application_url, data={'q': 'foo'},
method='post')
- self.assertIn('REQUEST_METHOD: POST', d('p').text())
- self.assertIn('q=foo', d('p').text())
+ self.assertIn('REQUEST_METHOD: POST', d.text())
+ self.assertIn('q=foo', d.text())
def test_session(self):
if HAS_REQUEST:
@@ -915,7 +917,7 @@ def test_session(self):
session.headers.update({'X-FOO': 'bar'})
d = pq(url=self.application_url, data={'q': 'foo'},
method='get', session=session)
- self.assertIn('HTTP_X_FOO: bar', d('p').text())
+ self.assertIn('HTTP_X_FOO: bar', d.text())
else:
self.skipTest('no requests library')
@@ -925,6 +927,7 @@ def tearDown(self):
class TestWebScrappingEncoding(TestCase):
+ @pytest.mark.skip('No longer possible to query this url')
def test_get(self):
d = pq(url='http://ru.wikipedia.org/wiki/Заглавная_страница',
method='get')
diff --git a/tox.ini b/tox.ini
index 8f206df..7455adf 100644
--- a/tox.ini
+++ b/tox.ini
@@ -1,5 +1,5 @@
[tox]
-envlist=py38,py39,py310,py311,py312
+envlist=py311,py312
[testenv]
whitelist_externals=
@@ -15,7 +15,7 @@ deps =
[testenv:lint]
skipsdist=true
skip_install=true
-basepython = python3.11
+basepython = python3.12
commands =
ruff check
deps =
@@ -24,7 +24,7 @@ deps =
[testenv:docs]
skip_install=false
skipsdist=true
-basepython = python3.11
+basepython = python3.12
changedir = docs
deps =
sphinx