From dde231b117018242cc0fd6d0e19f99007bc9fdc91c3e52a5048cd31bfe0ab2c3 Mon Sep 17 00:00:00 2001 From: Matej Cepl Date: Fri, 1 Nov 2019 10:51:33 +0000 Subject: [PATCH] - Add pytest4-mhroncok.patch by Miro Hroncok from gh#html5lib/html5lib-python#414 to make testsuite passing under pytest4+. OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-html5lib?expand=0&rev=36 --- pytest4-mhroncok.patch | 143 ++++++++++++++++++++++++++++++++++++++++ python-html5lib.changes | 9 ++- python-html5lib.spec | 6 +- 3 files changed, 156 insertions(+), 2 deletions(-) create mode 100644 pytest4-mhroncok.patch diff --git a/pytest4-mhroncok.patch b/pytest4-mhroncok.patch new file mode 100644 index 0000000..df254b7 --- /dev/null +++ b/pytest4-mhroncok.patch @@ -0,0 +1,143 @@ +From dd117cc62d961573e9867d79ae1c3461a42e6167 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= +Date: Thu, 28 Mar 2019 01:45:43 +0100 +Subject: [PATCH] Support pytest 4 + +Fixes https://github.com/html5lib/html5lib-python/issues/411 +--- + html5lib/tests/test_encoding.py | 4 ++-- + html5lib/tests/test_sanitizer.py | 14 +++++++------- + html5lib/tests/test_serializer.py | 2 +- + html5lib/tests/test_stream.py | 7 ++++--- + html5lib/tests/test_treewalkers.py | 2 +- + requirements-test.txt | 2 +- + tox.ini | 2 +- + 7 files changed, 17 insertions(+), 16 deletions(-) + +--- a/html5lib/tests/test_encoding.py ++++ b/html5lib/tests/test_encoding.py +@@ -94,13 +94,13 @@ def runPreScanEncodingTest(data, encodin + + assert encoding == stream.charEncoding[0].name, errorMessage(data, encoding, stream.charEncoding[0].name) + +- ++@pytest.mark.skip(reason="broken under pytest4") + def test_encoding(): + for filename in get_data_files("encoding"): + tests = _TestData(filename, b"data", encoding=None) + for test in tests: +- yield (runParserEncodingTest, test[b'data'], test[b'encoding']) +- yield (runPreScanEncodingTest, test[b'data'], test[b'encoding']) ++ runParserEncodingTest(test[b'data'], test[b'encoding']) ++ runPreScanEncodingTest(test[b'data'], test[b'encoding']) + + + # pylint:disable=wrong-import-position +--- a/html5lib/tests/test_sanitizer.py ++++ b/html5lib/tests/test_sanitizer.py +@@ -67,19 +67,19 @@ def test_sanitizer(): + 'tfoot', 'th', 'thead', 'tr', 'select']: + continue # TODO + if tag_name == 'image': +- yield (runSanitizerTest, "test_should_allow_%s_tag" % tag_name, ++ runSanitizerTest("test_should_allow_%s_tag" % tag_name, + "foo <bad>bar</bad> baz", + "<%s title='1'>foo bar baz" % (tag_name, tag_name)) + elif tag_name == 'br': +- yield (runSanitizerTest, "test_should_allow_%s_tag" % tag_name, ++ runSanitizerTest("test_should_allow_%s_tag" % tag_name, + "
foo <bad>bar</bad> baz
", + "<%s title='1'>foo bar baz" % (tag_name, tag_name)) + elif tag_name in constants.voidElements: +- yield (runSanitizerTest, "test_should_allow_%s_tag" % tag_name, ++ runSanitizerTest("test_should_allow_%s_tag" % tag_name, + "<%s title=\"1\"/>foo <bad>bar</bad> baz" % tag_name, + "<%s title='1'>foo bar baz" % (tag_name, tag_name)) + else: +- yield (runSanitizerTest, "test_should_allow_%s_tag" % tag_name, ++ runSanitizerTest("test_should_allow_%s_tag" % tag_name, + "<%s title=\"1\">foo <bad>bar</bad> baz" % (tag_name, tag_name), + "<%s title='1'>foo bar baz" % (tag_name, tag_name)) + +@@ -93,7 +93,7 @@ def test_sanitizer(): + attribute_value = 'foo' + if attribute_name in sanitizer.attr_val_is_uri: + attribute_value = '%s://sub.domain.tld/path/object.ext' % sanitizer.allowed_protocols[0] +- yield (runSanitizerTest, "test_should_allow_%s_attribute" % attribute_name, ++ runSanitizerTest("test_should_allow_%s_attribute" % attribute_name, + "

foo <bad>bar</bad> baz

" % (attribute_name, attribute_value), + "

foo bar baz

" % (attribute_name, attribute_value)) + +@@ -101,7 +101,7 @@ def test_sanitizer(): + rest_of_uri = '//sub.domain.tld/path/object.ext' + if protocol == 'data': + rest_of_uri = 'image/png;base64,aGVsbG8gd29ybGQ=' +- yield (runSanitizerTest, "test_should_allow_uppercase_%s_uris" % protocol, ++ runSanitizerTest("test_should_allow_uppercase_%s_uris" % protocol, + "foo" % (protocol, rest_of_uri), + """foo""" % (protocol, rest_of_uri)) + +@@ -110,7 +110,7 @@ def test_sanitizer(): + if protocol == 'data': + rest_of_uri = 'image/png;base64,aGVsbG8gd29ybGQ=' + protocol = protocol.upper() +- yield (runSanitizerTest, "test_should_allow_uppercase_%s_uris" % protocol, ++ runSanitizerTest("test_should_allow_uppercase_%s_uris" % protocol, + "foo" % (protocol, rest_of_uri), + """foo""" % (protocol, rest_of_uri)) + +--- a/html5lib/tests/test_serializer.py ++++ b/html5lib/tests/test_serializer.py +@@ -222,4 +222,4 @@ def test_serializer(): + with open(filename) as fp: + tests = json.load(fp) + for test in tests['tests']: +- yield runSerializerTest, test["input"], test["expected"], test.get("options", {}) ++ runSerializerTest(test["input"], test["expected"], test.get("options", {})) +--- a/html5lib/tests/test_stream.py ++++ b/html5lib/tests/test_stream.py +@@ -308,9 +308,10 @@ def test_invalid_codepoints(inp, num): + ("'\\uD800\\uD800\\uD800'", 3), + ("'a\\uD800a\\uD800a\\uD800a'", 3), + ("'\\uDFFF\\uDBFF'", 2), +- pytest.mark.skipif(sys.maxunicode == 0xFFFF, +- ("'\\uDBFF\\uDFFF'", 2), +- reason="narrow Python")]) ++ pytest.param( ++ "'\\uDBFF\\uDFFF'", 2, ++ marks=pytest.mark.skipif(sys.maxunicode == 0xFFFF, ++ reason="narrow Python"))]) + def test_invalid_codepoints_surrogates(inp, num): + inp = eval(inp) # pylint:disable=eval-used + fp = StringIO(inp) +--- a/html5lib/tests/test_treewalkers.py ++++ b/html5lib/tests/test_treewalkers.py +@@ -99,7 +99,7 @@ def test_treewalker_six_mix(): + + for tree in sorted(treeTypes.items()): + for intext, attrs, expected in sm_tests: +- yield runTreewalkerEditTest, intext, expected, attrs, tree ++ runTreewalkerEditTest(intext, expected, attrs, tree) + + + @pytest.mark.parametrize("tree,char", itertools.product(sorted(treeTypes.items()), ["x", "\u1234"])) +--- a/requirements-test.txt ++++ b/requirements-test.txt +@@ -4,7 +4,7 @@ tox + + flake8<3.0 + +-pytest==3.2.5 ++pytest>=4.3,<4.4 + coverage + pytest-expect>=1.1,<2.0 + mock +--- a/tox.ini ++++ b/tox.ini +@@ -1,5 +1,5 @@ + [tox] +-envlist = {py27,py33,py34,py35,py36,pypy}-{base,six19,optional} ++envlist = {py27,py34,py35,py36,py37,py38,pypy}-{base,six19,optional} + + [testenv] + deps = diff --git a/python-html5lib.changes b/python-html5lib.changes index a162459..ca581ac 100644 --- a/python-html5lib.changes +++ b/python-html5lib.changes @@ -1,7 +1,14 @@ +------------------------------------------------------------------- +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 -s with plain %fdupes; hardlinks are better. +- Replace %fdupes with plain %fdupes; hardlinks are better. ------------------------------------------------------------------- Fri Jul 19 12:28:28 UTC 2019 - Tomáš Chvátal diff --git a/python-html5lib.spec b/python-html5lib.spec index 4fe8965..adbc4b3 100644 --- a/python-html5lib.spec +++ b/python-html5lib.spec @@ -24,13 +24,16 @@ 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|FEATURE}-{OPENSUSE|SLE|UPSTREAM} name-of-file.patch gh#html5lib/html5lib-python#414 mcepl@suse.com +# This patch makes testsuite pass with pytest4 +Patch0: pytest4-mhroncok.patch BuildRequires: %{python_module Genshi} BuildRequires: %{python_module datrie} BuildRequires: %{python_module lxml} BuildRequires: %{python_module mock} # https://github.com/html5lib/html5lib-python/issues/411 -BuildRequires: %{python_module pytest < 4.0} BuildRequires: %{python_module pytest-expect} +BuildRequires: %{python_module pytest} BuildRequires: %{python_module setuptools >= 18.5} BuildRequires: %{python_module six >= 1.9} BuildRequires: %{python_module webencodings} @@ -55,6 +58,7 @@ simple custom format %prep %setup -q -n html5lib-%{version} +%autopatch -p1 %build %python_build