From 187d493f852284fed0a87d6e637eff0cfc5362a443201390dae9ff3b55792acb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrian=20Schr=C3=B6ter?= Date: Fri, 3 May 2024 20:58:19 +0200 Subject: [PATCH] Sync from SUSE:SLFO:Main python-html5lib revision 7c990556efc2e62c8dda9886f5e72c2a --- .gitattributes | 23 ++++ html5lib-1.1.tar.gz | 3 + pytest6.patch | 163 +++++++++++++++++++++++++ pytest74.patch | 26 ++++ python-html5lib-no-mock.patch | 13 ++ python-html5lib.changes | 224 ++++++++++++++++++++++++++++++++++ python-html5lib.spec | 80 ++++++++++++ 7 files changed, 532 insertions(+) create mode 100644 .gitattributes create mode 100644 html5lib-1.1.tar.gz create mode 100644 pytest6.patch create mode 100644 pytest74.patch create mode 100644 python-html5lib-no-mock.patch create mode 100644 python-html5lib.changes create mode 100644 python-html5lib.spec diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..9b03811 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,23 @@ +## Default LFS +*.7z filter=lfs diff=lfs merge=lfs -text +*.bsp filter=lfs diff=lfs merge=lfs -text +*.bz2 filter=lfs diff=lfs merge=lfs -text +*.gem filter=lfs diff=lfs merge=lfs -text +*.gz filter=lfs diff=lfs merge=lfs -text +*.jar filter=lfs diff=lfs merge=lfs -text +*.lz filter=lfs diff=lfs merge=lfs -text +*.lzma filter=lfs diff=lfs merge=lfs -text +*.obscpio filter=lfs diff=lfs merge=lfs -text +*.oxt filter=lfs diff=lfs merge=lfs -text +*.pdf filter=lfs diff=lfs merge=lfs -text +*.png filter=lfs diff=lfs merge=lfs -text +*.rpm filter=lfs diff=lfs merge=lfs -text +*.tbz filter=lfs diff=lfs merge=lfs -text +*.tbz2 filter=lfs diff=lfs merge=lfs -text +*.tgz filter=lfs diff=lfs merge=lfs -text +*.ttf filter=lfs diff=lfs merge=lfs -text +*.txz filter=lfs diff=lfs merge=lfs -text +*.whl filter=lfs diff=lfs merge=lfs -text +*.xz filter=lfs diff=lfs merge=lfs -text +*.zip filter=lfs diff=lfs merge=lfs -text +*.zst filter=lfs diff=lfs merge=lfs -text diff --git a/html5lib-1.1.tar.gz b/html5lib-1.1.tar.gz new file mode 100644 index 0000000..11bd2ce --- /dev/null +++ b/html5lib-1.1.tar.gz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b2e5b40261e20f354d198eae92afc10d750afb487ed5e50f9c4eaf07c184146f +size 272215 diff --git a/pytest6.patch b/pytest6.patch new file mode 100644 index 0000000..a6f610d --- /dev/null +++ b/pytest6.patch @@ -0,0 +1,163 @@ +From 2c19b9899ab3a3e8bd0ca35e5d78544334204169 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= +Date: Sat, 8 Aug 2020 13:39:22 +0200 +Subject: [PATCH] Use Node.from_parent() constructor to support pytest 6 + +Add a wrapper not to break pytest 4 (needed for Python 2 support). + + ============================= test session starts ============================== + platform linux -- Python 3.9.0b5, pytest-6.0.1, py-1.9.0, pluggy-0.13.1 + rootdir: /builddir/build/BUILD/html5lib-1.1, configfile: pytest.ini + plugins: expect-1.1.0 + collected 0 items / 1 error + + ==================================== ERRORS ==================================== + ________________________ ERROR collecting test session _________________________ + /usr/lib/python3.9/site-packages/pluggy/hooks.py:286: in __call__ + return self._hookexec(self, self.get_hookimpls(), kwargs) + /usr/lib/python3.9/site-packages/pluggy/manager.py:93: in _hookexec + return self._inner_hookexec(hook, methods, kwargs) + /usr/lib/python3.9/site-packages/pluggy/manager.py:84: in + self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall( + html5lib/tests/conftest.py:105: in pytest_collect_file + return TokenizerFile(path, parent) + /usr/lib/python3.9/site-packages/_pytest/nodes.py:95: in __call__ + warnings.warn(NODE_USE_FROM_PARENT.format(name=self.__name__), stacklevel=2) + E pytest.PytestDeprecationWarning: Direct construction of TokenizerFile has been deprecated, please use TokenizerFile.from_parent. + E See https://docs.pytest.org/en/stable/deprecations.html#node-construction-changed-to-node-from-parent for more details. + +Fixes https://github.com/html5lib/html5lib-python/issues/505 +--- + html5lib/tests/conftest.py | 15 ++++++++++++--- + html5lib/tests/sanitizer.py | 2 +- + html5lib/tests/tokenizer.py | 10 +++++----- + html5lib/tests/tree_construction.py | 20 ++++++++++---------- + requirements-test.txt | 2 +- + 5 files changed, 29 insertions(+), 20 deletions(-) + +diff --git a/html5lib/tests/conftest.py b/html5lib/tests/conftest.py +index dad167c5..fffeb50c 100644 +--- a/html5lib/tests/conftest.py ++++ b/html5lib/tests/conftest.py +@@ -99,10 +99,19 @@ def pytest_collect_file(path, parent): + + if _tree_construction in dir_and_parents: + if path.ext == ".dat": +- return TreeConstructionFile(path, parent) ++ return TreeConstructionFile.from_parent(parent, fspath=path) + elif _tokenizer in dir_and_parents: + if path.ext == ".test": +- return TokenizerFile(path, parent) ++ return TokenizerFile.from_parent(parent, fspath=path) + elif _sanitizer_testdata in dir_and_parents: + if path.ext == ".dat": +- return SanitizerFile(path, parent) ++ return SanitizerFile.from_parent(parent, fspath=path) ++ ++ ++# Tiny wrapper to allow .from_parent constructors on older pytest for PY27 ++if not hasattr(pytest.Item.__base__, "from_parent"): ++ @classmethod ++ def from_parent(cls, parent, **kwargs): ++ return cls(parent=parent, **kwargs) ++ ++ pytest.Item.__base__.from_parent = from_parent +diff --git a/html5lib/tests/sanitizer.py b/html5lib/tests/sanitizer.py +index bb483421..16e53868 100644 +--- a/html5lib/tests/sanitizer.py ++++ b/html5lib/tests/sanitizer.py +@@ -13,7 +13,7 @@ def collect(self): + with codecs.open(str(self.fspath), "r", encoding="utf-8") as fp: + tests = json.load(fp) + for i, test in enumerate(tests): +- yield SanitizerTest(str(i), self, test=test) ++ yield SanitizerTest.from_parent(self, name=str(i), test=test) + + + class SanitizerTest(pytest.Item): +diff --git a/html5lib/tests/tokenizer.py b/html5lib/tests/tokenizer.py +index 47264cc3..cc9897a4 100644 +--- a/html5lib/tests/tokenizer.py ++++ b/html5lib/tests/tokenizer.py +@@ -192,7 +192,7 @@ def collect(self): + tests = json.load(fp) + if 'tests' in tests: + for i, test in enumerate(tests['tests']): +- yield TokenizerTestCollector(str(i), self, testdata=test) ++ yield TokenizerTestCollector.from_parent(self, name=str(i), testdata=test) + + + class TokenizerTestCollector(pytest.Collector): +@@ -207,10 +207,10 @@ def __init__(self, name, parent=None, config=None, session=None, testdata=None): + def collect(self): + for initialState in self.testdata["initialStates"]: + initialState = capitalize(initialState) +- item = TokenizerTest(initialState, +- self, +- self.testdata, +- initialState) ++ item = TokenizerTest.from_parent(self, ++ name=initialState, ++ test=self.testdata, ++ initialState=initialState) + if self.testdata["input"] is None: + item.add_marker(pytest.mark.skipif(True, reason="Relies on lone surrogates")) + yield item +diff --git a/html5lib/tests/tree_construction.py b/html5lib/tests/tree_construction.py +index 1ef6e725..fb0657bf 100644 +--- a/html5lib/tests/tree_construction.py ++++ b/html5lib/tests/tree_construction.py +@@ -26,7 +26,7 @@ class TreeConstructionFile(pytest.File): + def collect(self): + tests = TestData(str(self.fspath), "data") + for i, test in enumerate(tests): +- yield TreeConstructionTest(str(i), self, testdata=test) ++ yield TreeConstructionTest.from_parent(self, name=str(i), testdata=test) + + + class TreeConstructionTest(pytest.Collector): +@@ -48,11 +48,11 @@ def _getParserTests(self, treeName, treeAPIs): + nodeid = "%s::parser::namespaced" % treeName + else: + nodeid = "%s::parser::void-namespace" % treeName +- item = ParserTest(nodeid, +- self, +- self.testdata, +- treeAPIs["builder"] if treeAPIs is not None else None, +- namespaceHTMLElements) ++ item = ParserTest.from_parent(self, ++ name=nodeid, ++ test=self.testdata, ++ treeClass=treeAPIs["builder"] if treeAPIs is not None else None, ++ namespaceHTMLElements=namespaceHTMLElements) + item.add_marker(getattr(pytest.mark, treeName)) + item.add_marker(pytest.mark.parser) + if namespaceHTMLElements: +@@ -61,10 +61,10 @@ def _getParserTests(self, treeName, treeAPIs): + + def _getTreeWalkerTests(self, treeName, treeAPIs): + nodeid = "%s::treewalker" % treeName +- item = TreeWalkerTest(nodeid, +- self, +- self.testdata, +- treeAPIs) ++ item = TreeWalkerTest.from_parent(self, ++ name=nodeid, ++ test=self.testdata, ++ treeAPIs=treeAPIs) + item.add_marker(getattr(pytest.mark, treeName)) + item.add_marker(pytest.mark.treewalker) + yield item +diff --git a/requirements-test.txt b/requirements-test.txt +index 703d0e69..57f8f617 100644 +--- a/requirements-test.txt ++++ b/requirements-test.txt +@@ -3,7 +3,7 @@ + tox>=3.15.1,<4 + flake8>=3.8.1,<3.9 + pytest>=4.6.10,<5 ; python_version < '3' +-pytest>=5.4.2,<6 ; python_version >= '3' ++pytest>=5.4.2,<7 ; python_version >= '3' + coverage>=5.1,<6 + pytest-expect>=1.1.0,<2 + mock>=3.0.5,<4 ; python_version < '3.6' diff --git a/pytest74.patch b/pytest74.patch new file mode 100644 index 0000000..656abd0 --- /dev/null +++ b/pytest74.patch @@ -0,0 +1,26 @@ +Index: html5lib-1.1/html5lib/tests/tokenizer.py +=================================================================== +--- html5lib-1.1.orig/html5lib/tests/tokenizer.py ++++ html5lib-1.1/html5lib/tests/tokenizer.py +@@ -246,7 +246,7 @@ class TokenizerTest(pytest.Item): + def repr_failure(self, excinfo): + traceback = excinfo.traceback + ntraceback = traceback.cut(path=__file__) +- excinfo.traceback = ntraceback.filter() ++ excinfo.traceback = ntraceback.filter(excinfo) + + return excinfo.getrepr(funcargs=True, + showlocals=False, +Index: html5lib-1.1/html5lib/tests/tree_construction.py +=================================================================== +--- html5lib-1.1.orig/html5lib/tests/tree_construction.py ++++ html5lib-1.1/html5lib/tests/tree_construction.py +@@ -135,7 +135,7 @@ class ParserTest(pytest.Item): + def repr_failure(self, excinfo): + traceback = excinfo.traceback + ntraceback = traceback.cut(path=__file__) +- excinfo.traceback = ntraceback.filter() ++ excinfo.traceback = ntraceback.filter(excinfo) + + return excinfo.getrepr(funcargs=True, + showlocals=False, diff --git a/python-html5lib-no-mock.patch b/python-html5lib-no-mock.patch new file mode 100644 index 0000000..009d56f --- /dev/null +++ b/python-html5lib-no-mock.patch @@ -0,0 +1,13 @@ +Index: html5lib-1.1/html5lib/tests/test_meta.py +=================================================================== +--- html5lib-1.1.orig/html5lib/tests/test_meta.py 2020-06-23 01:23:02.000000000 +0200 ++++ html5lib-1.1/html5lib/tests/test_meta.py 2022-03-21 14:42:19.011204038 +0100 +@@ -1,7 +1,7 @@ + from __future__ import absolute_import, division, unicode_literals + + import six +-from mock import Mock ++from unittest.mock import Mock + + from . import support + diff --git a/python-html5lib.changes b/python-html5lib.changes new file mode 100644 index 0000000..07f8610 --- /dev/null +++ b/python-html5lib.changes @@ -0,0 +1,224 @@ +------------------------------------------------------------------- +Thu Jul 27 07:50:37 UTC 2023 - Markéta Machová + +- Add pytest74.patch to fix tests with pytest 7.4+ + +------------------------------------------------------------------- +Fri Apr 21 12:26:16 UTC 2023 - Dirk Müller + +- add sle15_python_module_pythons (jsc#PED-68) + +------------------------------------------------------------------- +Thu Apr 13 22:41:51 UTC 2023 - Matej Cepl + +- Make calling of %{sle15modernpython} optional. + +------------------------------------------------------------------- +Thu Jul 14 02:22:46 UTC 2022 - Steve Kowalik + +- Remove BuildRequires on mock. + +------------------------------------------------------------------- +Mon Mar 21 14:10:17 UTC 2022 - pgajdos@suse.com + +- do not require python-mock for build +- added patches + fix https://github.com/html5lib/html5lib-python/issues/541 + + python-html5lib-no-mock.patch + +------------------------------------------------------------------- +Thu Aug 27 14:03:46 UTC 2020 - Marketa Calabkova + +- Update to 1.1 + * Drop support for Python 3.3 and 3.4. + * Try to import from ``collections.abc`` to remove DeprecationWarning and ensure + ``html5lib`` keeps working in future Python versions. (#403) + * Drop optional ``datrie`` dependency. (#442) +- Drop merged patches: + * pytest4-mhroncok.patch + * collections-abc.patch + * pytest5.patch +- Add upstream patch pytest6.patch + +------------------------------------------------------------------- +Fri May 29 09:17:23 UTC 2020 - Tomáš Chvátal + +- Add patch to fix run with pytest5: + * pytest5.patch + +------------------------------------------------------------------- +Wed May 6 07:41:38 UTC 2020 - Tomáš Chvátal + +- Add patch to not collide with collections deprecation: + * collections-abc.patch + +------------------------------------------------------------------- +Wed Jan 15 12:31:39 UTC 2020 - Tomáš Chvátal + +- Restrict pytest to < 5.0 as it broke with 5.3 and upstream + still didn't bother to merge support for even pytest 4+... + +------------------------------------------------------------------- +Tue Dec 3 14:25:29 UTC 2019 - Tomáš Chvátal + +- Fix comments in the spec file + +------------------------------------------------------------------- +Fri Nov 1 11:50:36 CET 2019 - Matej Cepl + +- Add pytest4-mhroncok.patch by Miro Hroncok from + gh#html5lib/html5lib-python#414 to make testsuite passing under + pytest4+. + +------------------------------------------------------------------- +Mon Oct 14 13:39:22 UTC 2019 - Matej Cepl + +- Replace %fdupes with plain %fdupes; hardlinks are better. + +------------------------------------------------------------------- +Fri Jul 19 12:28:28 UTC 2019 - Tomáš Chvátal + +- Restrict pytest4 for now as upstream supports only 3 series + at the moment + +------------------------------------------------------------------- +Tue Dec 4 12:48:57 UTC 2018 - Matej Cepl + +- Remove superfluous devel dependency for noarch package + +------------------------------------------------------------------- +Wed Dec 13 13:31:39 UTC 2017 - tchvatal@suse.com + +- Version update to latest 1.0.1 release: + * Dropped support for py 2.6 + * Documentation update + * Fixes for python 3.7 and 3.6 + +------------------------------------------------------------------- +Tue Dec 5 16:42:07 UTC 2017 - opensuse@dstoecker.de + +- update to 1.0b10 + +------------------------------------------------------------------- +Fri Apr 7 16:07:01 UTC 2017 - toddrme2178@gmail.com + +- html5lib has a hard dependency on python-webencodings. + It will fail at import time without it. + +------------------------------------------------------------------- +Tue Apr 4 14:54:02 UTC 2017 - aloisio@gmx.com + +- Updated to version 0.999999999 (see CHANGES.rst) +- Converted to single-spec +- Dropped coerce_comments_to_work_with_lxml.patch (accepted + upstream) + +------------------------------------------------------------------- +Fri Feb 12 14:54:04 UTC 2016 - toddrme2178@gmail.com + +- Add coerce_comments_to_work_with_lxml.patch + Fixes compatibility with python-lxml 3.5+, which adds validation + for xml comments. + Should be in next release/ +- Re-enable tests. + +------------------------------------------------------------------- +Tue Feb 2 11:46:24 UTC 2016 - toddrme2178@gmail.com + +- Disable broken tests. + Check if they are working again in the next release. + +------------------------------------------------------------------- +Mon Feb 1 10:33:59 UTC 2016 - toddrme2178@gmail.com + +- update to version 0.9999999: + * Fix #195: fix the sanitizer to drop broken URLs (it threw an + exception between 0.9999 and 0.999999). + +------------------------------------------------------------------- +Mon Aug 3 16:30:05 UTC 2015 - tbechtold@suse.com + +- Relax python-lxml BuildRequires and Requires. html5lib should + also work with older python-lxml modules. + +------------------------------------------------------------------- +Mon Jul 27 19:04:15 UTC 2015 - aloisio@gmx.com + +- Update to version 0.999999 + * Fix #189: fix the sanitizer to allow relative URLs again + (as it did prior to 0.9999/1.0b5). +- Aligned version requirements with PyPI + +------------------------------------------------------------------- +Fri Jul 24 20:28:37 UTC 2015 - seife+obs@b1-systems.com + +- Fix non-SUSE build by conditionalizing Recommends: tags + +------------------------------------------------------------------- +Wed May 6 15:02:06 UTC 2015 - benoit.monin@gmx.fr + +- update to version 0.99999: + * Fix #188: fix the sanitizer to not throw an exception when + sanitizing bogus data URLs. +- additional changes from version 0.9999: + * Fix #153: Sanitizer fails to treat some attributes as URLs. + Despite how this sounds, this has no known security + implications. No known version of IE (5.5 to current), Firefox + (3 to current), Safari (6 to current), Chrome (1 to current), + or Opera (12 to current) will run any script provided in these + attributes. + * Pass error message to the ParseError exception in strict + parsing mode. + * Allow data URIs in the sanitizer, with a whitelist of + content-types. + * Add support for Python implementations that don’t support lone + surrogates (read: Jython). Fixes #2. + * Remove localization of error messages. This functionality was + totally unused (and untested that everything was localizable), + so we may as well follow numerous browsers in not supporting + translating technical strings. + * Expose treewalkers.pprint as a public API. + * Add a documentEncoding property to HTML5Parser, fix #121. +- update project URL + +------------------------------------------------------------------- +Mon May 26 22:01:47 UTC 2014 - hpj@urpla.net + +- update to 0.999 + - Fix #127: add work-around for CPython issue #20007: .read(0) on + http.client.HTTPResponse drops the rest of the content. + - Fix #115: lxml treewalker can now deal with fragments containing, at their + root level, text nodes with non-ASCII characters on Python 2. + +- enable tests and include test suite for further validations + for distributions > 11.1 and SLES 10 + +------------------------------------------------------------------- +Tue Oct 22 13:29:08 UTC 2013 - toddrme2178@gmail.com + +- Update to 0.99 + * No changes, just updated version number +- Add additional dependencies + +------------------------------------------------------------------- +Thu Mar 29 09:54:02 UTC 2012 - saschpe@suse.de + +- Use upstream tarball +- Don't install tests, but install README + +------------------------------------------------------------------- +Sat Feb 11 12:41:52 UTC 2012 - alexandre@exatati.com.br + +- Update to 0.95: + - Sorry, no changelog atm. +- Regenerate spec file with py2pack. + +------------------------------------------------------------------- +Mon Jan 18 00:16:01 UTC 2010 - alexandre@exatati.com.br + +- Update to 0.90. + +------------------------------------------------------------------- +Wed Oct 14 16:53:20 UTC 2009 - alexandre@exatati.com.br + +- Initial package (0.11.1) for openSUSE. diff --git a/python-html5lib.spec b/python-html5lib.spec new file mode 100644 index 0000000..0207202 --- /dev/null +++ b/python-html5lib.spec @@ -0,0 +1,80 @@ +# +# spec file for package python-html5lib +# +# 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 +# upon. The license for this file, and modifications and additions to the +# file, is the same license as for the pristine package itself (unless the +# license for the pristine package is not an Open Source License, in which +# case the license is the MIT License). An "Open Source License" is a +# license that conforms to the Open Source Definition (Version 1.9) +# published by the Open Source Initiative. + +# Please submit bugfixes or comments via https://bugs.opensuse.org/ +# + + +%{?!python_module:%define python_module() python-%{**} python3-%{**}} +%{?sle15_python_module_pythons} +Name: python-html5lib +Version: 1.1 +Release: 0 +Summary: HTML parser based on the WHAT-WG Web Applications 1 +License: MIT +URL: https://github.com/html5lib/html5lib-python +Source: https://files.pythonhosted.org/packages/source/h/html5lib/html5lib-%{version}.tar.gz +# PATCH-FIX_UPSTREAM https://github.com/html5lib/html5lib-python/commit/2c19b9899ab3a3e8bd0ca35e5d78544334204169 Use Node.from_parent() constructor to support pytest 6 +Patch0: pytest6.patch +# https://github.com/html5lib/html5lib-python/issues/541 +Patch1: python-html5lib-no-mock.patch +# PATCH-FIX-UPSTREAM https://github.com/html5lib/html5lib-python/pull/570 adapt testsuite to changes in pytest 7.4 +Patch2: pytest74.patch +BuildRequires: %{python_module Genshi} +BuildRequires: %{python_module lxml} +BuildRequires: %{python_module pytest >= 4.0} +BuildRequires: %{python_module pytest-expect} +BuildRequires: %{python_module setuptools >= 18.5} +BuildRequires: %{python_module six >= 1.9} +BuildRequires: %{python_module webencodings} +BuildRequires: fdupes +BuildRequires: python-rpm-macros +Requires: python-six >= 1.9 +Requires: python-webencodings +Recommends: python-Genshi +Recommends: python-lxml +BuildArch: noarch +%python_subpackages + +%description +HTML parser designed to follow the HTML5 +specification. The parser is designed to handle all flavours of HTML and +parses invalid documents using well-defined error handling rules compatible +with the behaviour of major desktop web browsers. + +Output is to a tree structure; the current release supports output to +DOM, ElementTree, lxml and BeautifulSoup tree formats as well as a +simple custom format + +%prep +%setup -q -n html5lib-%{version} +%autopatch -p1 + +%build +%python_build + +%install +%python_install +%python_expand %fdupes %{buildroot}%{$python_sitelib} + +%check +%pytest --tb=short + +%files %{python_files} +%license LICENSE +%doc CHANGES.rst README.rst +%{python_sitelib}/html5lib/ +%{python_sitelib}/html5lib-%{version}-py%{python_version}.egg-info + +%changelog