diff --git a/make_webtest_optional.patch b/make_webtest_optional.patch new file mode 100644 index 0000000..0bc5a0d --- /dev/null +++ b/make_webtest_optional.patch @@ -0,0 +1,38 @@ +--- + tests/test_pyquery.py | 11 ++++++++--- + 1 file changed, 8 insertions(+), 3 deletions(-) + +--- a/tests/test_pyquery.py ++++ b/tests/test_pyquery.py +@@ -7,9 +7,12 @@ import time + from lxml import etree + from pyquery.pyquery import PyQuery as pq, no_default + from pyquery.openers import HAS_REQUEST +-from webtest import http +-from webtest.debugapp import debug_app +-from unittest import TestCase ++from unittest import TestCase, skipIf ++try: ++ from webtest import http ++ from webtest.debugapp import debug_app ++except (ImportError, ModuleNotFoundError): ++ http = None + + sys.path.insert(0, os.path.dirname(os.path.dirname(__file__))) + +@@ -835,6 +838,7 @@ class TestXMLNamespace(TestCase): + self.assertEqual(repr(val), repr('b')) + + ++@skipIf(http is None, "Cannot test without WebTest") + class TestWebScrapping(TestCase): + + def setUp(self): +@@ -879,6 +883,7 @@ class TestWebScrappingEncoding(TestCase) + self.assertEqual(d('#pt-login').text(), u'Войти') + + ++@skipIf(http is None, "Cannot test without WebTest") + class TestWebScrappingTimeouts(TestCase): + + def setUp(self): diff --git a/python-pyquery.changes b/python-pyquery.changes index 853b0b1..161a5a4 100644 --- a/python-pyquery.changes +++ b/python-pyquery.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Fri Feb 17 16:46:13 UTC 2023 - Matej Cepl + +- Add make_webtest_optional.patch to allow testing without + WebTest module. + ------------------------------------------------------------------- Fri Aug 19 11:41:24 UTC 2022 - Ben Greiner diff --git a/python-pyquery.spec b/python-pyquery.spec index f5d0a35..499dd49 100644 --- a/python-pyquery.spec +++ b/python-pyquery.spec @@ -1,7 +1,7 @@ # # spec file # -# Copyright (c) 2022 SUSE LLC +# Copyright (c) 2023 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -16,7 +16,6 @@ # -%{?!python_module:%define python_module() python3-%{**}} %define skip_python2 1 %global flavor @BUILD_FLAVOR@%{nil} %if "%{flavor}" == "test" @@ -34,6 +33,9 @@ License: BSD-3-Clause Group: Development/Languages/Python URL: https://pypi.python.org/pypi/pyquery Source: https://files.pythonhosted.org/packages/source/p/pyquery/pyquery-%{version}.tar.gz +# PATCH-FIX-OPENSUSE make_webtest_optional.patch mcepl@suse.com +# Make it possible to run test suite (albeit partial) without WebTest module +Patch0: make_webtest_optional.patch BuildRequires: %{python_module cssselect > 0.7.9} BuildRequires: %{python_module lxml >= 2.1} BuildRequires: %{python_module setuptools} @@ -44,9 +46,11 @@ Requires: python-lxml >= 2.1 BuildArch: noarch %if %{with test} BuildRequires: %{python_module WebOb > 1.1.9} -BuildRequires: %{python_module WebTest} BuildRequires: %{python_module pytest} BuildRequires: %{python_module requests} +%if 0%{?suse_version} > 1550 +BuildRequires: %{python_module WebTest} +%endif %endif %python_subpackages @@ -56,7 +60,7 @@ as much as possible the similar to jQuery. Pyquery uses lxml for fast XML and HTML manipulation. %prep -%setup -q -n pyquery-%{version} +%autosetup -p1 -n pyquery-%{version} %build %python_build