!70 Fix test_elementtree with Expat 2.6.0
From: @zhangzikang1992 Reviewed-by: @yangzhao_kl, @dillon_chen Signed-off-by: @dillon_chen
This commit is contained in:
commit
3cbb73bc68
92
Fix-test_elementtree-with-Expat-2.6.0.patch
Normal file
92
Fix-test_elementtree-with-Expat-2.6.0.patch
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
From e3012a702dea2b03830fe00a5e8f7a429bbc3f42 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Serhiy Storchaka <storchaka@gmail.com>
|
||||||
|
Date: Mon, 22 Apr 2024 16:52:26 +0800
|
||||||
|
Subject: [PATCH] Fix test_elementtree with Expat 2.6.0
|
||||||
|
|
||||||
|
---
|
||||||
|
src/lxml/tests/test_elementtree.py | 62 +++++++++++++++++++-----------
|
||||||
|
1 file changed, 39 insertions(+), 23 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/src/lxml/tests/test_elementtree.py b/src/lxml/tests/test_elementtree.py
|
||||||
|
index 8ccf444..ef923c5 100644
|
||||||
|
--- a/src/lxml/tests/test_elementtree.py
|
||||||
|
+++ b/src/lxml/tests/test_elementtree.py
|
||||||
|
@@ -10,6 +10,7 @@ import copy
|
||||||
|
import io
|
||||||
|
import operator
|
||||||
|
import os
|
||||||
|
+import pyexpat
|
||||||
|
import re
|
||||||
|
import sys
|
||||||
|
import textwrap
|
||||||
|
@@ -4383,29 +4384,44 @@ class _XMLPullParserTest(unittest.TestCase):
|
||||||
|
self.assertEqual([(action, elem.tag) for action, elem in events],
|
||||||
|
expected)
|
||||||
|
|
||||||
|
- def test_simple_xml(self):
|
||||||
|
- for chunk_size in (None, 1, 5):
|
||||||
|
- #with self.subTest(chunk_size=chunk_size):
|
||||||
|
- parser = self.etree.XMLPullParser()
|
||||||
|
- self.assert_event_tags(parser, [])
|
||||||
|
- self._feed(parser, "<!-- comment -->\n", chunk_size)
|
||||||
|
- self.assert_event_tags(parser, [])
|
||||||
|
- self._feed(parser,
|
||||||
|
- "<root>\n <element key='value'>text</element",
|
||||||
|
- chunk_size)
|
||||||
|
- self.assert_event_tags(parser, [])
|
||||||
|
- self._feed(parser, ">\n", chunk_size)
|
||||||
|
- self.assert_event_tags(parser, [('end', 'element')])
|
||||||
|
- self._feed(parser, "<element>text</element>tail\n", chunk_size)
|
||||||
|
- self._feed(parser, "<empty-element/>\n", chunk_size)
|
||||||
|
- self.assert_event_tags(parser, [
|
||||||
|
- ('end', 'element'),
|
||||||
|
- ('end', 'empty-element'),
|
||||||
|
- ])
|
||||||
|
- self._feed(parser, "</root>\n", chunk_size)
|
||||||
|
- self.assert_event_tags(parser, [('end', 'root')])
|
||||||
|
- root = self._close_and_return_root(parser)
|
||||||
|
- self.assertEqual(root.tag, 'root')
|
||||||
|
+ def test_simple_xml(self, chunk_size=None):
|
||||||
|
+ parser = self.etree.XMLPullParser()
|
||||||
|
+ self.assert_event_tags(parser, [])
|
||||||
|
+ self._feed(parser, "<!-- comment -->\n", chunk_size)
|
||||||
|
+ self.assert_event_tags(parser, [])
|
||||||
|
+ self._feed(parser,
|
||||||
|
+ "<root>\n <element key='value'>text</element",
|
||||||
|
+ chunk_size)
|
||||||
|
+ self.assert_event_tags(parser, [])
|
||||||
|
+ self._feed(parser, ">\n", chunk_size)
|
||||||
|
+ self.assert_event_tags(parser, [('end', 'element')])
|
||||||
|
+ self._feed(parser, "<element>text</element>tail\n", chunk_size)
|
||||||
|
+ self._feed(parser, "<empty-element/>\n", chunk_size)
|
||||||
|
+ self.assert_event_tags(parser, [
|
||||||
|
+ ('end', 'element'),
|
||||||
|
+ ('end', 'empty-element'),
|
||||||
|
+ ])
|
||||||
|
+ self._feed(parser, "</root>\n", chunk_size)
|
||||||
|
+ self.assert_event_tags(parser, [('end', 'root')])
|
||||||
|
+ root = self._close_and_return_root(parser)
|
||||||
|
+ self.assertEqual(root.tag, 'root')
|
||||||
|
+
|
||||||
|
+ def test_simple_xml_chunk_1(self):
|
||||||
|
+ if self.etree is not etree and pyexpat.version_info >= (2, 6, 0):
|
||||||
|
+ raise unittest.SkipTest(
|
||||||
|
+ "Feeding the parser by too small chunks defers parsing"
|
||||||
|
+ )
|
||||||
|
+ self.test_simple_xml(chunk_size=1)
|
||||||
|
+
|
||||||
|
+ def test_simple_xml_chunk_5(self):
|
||||||
|
+ if self.etree is not etree and pyexpat.version_info >= (2, 6, 0):
|
||||||
|
+ raise unittest.SkipTest(
|
||||||
|
+ "Feeding the parser by too small chunks defers parsing"
|
||||||
|
+ )
|
||||||
|
+ self.test_simple_xml(chunk_size=5)
|
||||||
|
+
|
||||||
|
+ def test_simple_xml_chunk_22(self):
|
||||||
|
+ self.test_simple_xml(chunk_size=22)
|
||||||
|
|
||||||
|
def test_feed_while_iterating(self):
|
||||||
|
parser = self.etree.XMLPullParser()
|
||||||
|
--
|
||||||
|
2.43.0
|
||||||
|
|
||||||
@ -7,13 +7,14 @@ The latest release works with all CPython versions from 2.7 to 3.7.
|
|||||||
|
|
||||||
Name: python-lxml
|
Name: python-lxml
|
||||||
Version: 5.1.0
|
Version: 5.1.0
|
||||||
Release: 1
|
Release: 2
|
||||||
Summary: XML processing library combining libxml2/libxslt with the ElementTree API
|
Summary: XML processing library combining libxml2/libxslt with the ElementTree API
|
||||||
License: BSD
|
License: BSD
|
||||||
URL: https://github.com/lxml/lxml
|
URL: https://github.com/lxml/lxml
|
||||||
Source0: https://files.pythonhosted.org/packages/2b/b4/bbccb250adbee490553b6a52712c46c20ea1ba533a643f1424b27ffc6845/lxml-5.1.0.tar.gz
|
Source0: https://files.pythonhosted.org/packages/2b/b4/bbccb250adbee490553b6a52712c46c20ea1ba533a643f1424b27ffc6845/lxml-5.1.0.tar.gz
|
||||||
|
|
||||||
Patch0: Skip-failing-test_iterparse_utf16_bom.patch
|
Patch0: Skip-failing-test_iterparse_utf16_bom.patch
|
||||||
|
Patch1: Fix-test_elementtree-with-Expat-2.6.0.patch
|
||||||
|
|
||||||
%description
|
%description
|
||||||
%{_description}
|
%{_description}
|
||||||
@ -77,6 +78,9 @@ make test
|
|||||||
%doc README.rst src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/readme.txt
|
%doc README.rst src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/readme.txt
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Tue Apr 23 2024 zhangzikang <zhangzikang@kylinos.cn> - 5.1.0-2
|
||||||
|
- Fix test_elementtree with Expat-2.6.0, resolve check error
|
||||||
|
|
||||||
* Wed Feb 07 2024 dongyuzhen <dongyuzhen@h-partners.com> - 5.1.0-1
|
* Wed Feb 07 2024 dongyuzhen <dongyuzhen@h-partners.com> - 5.1.0-1
|
||||||
- upgrade version to 5.1.0:
|
- upgrade version to 5.1.0:
|
||||||
- some incorrect declarations were removed from ``python.pxd``
|
- some incorrect declarations were removed from ``python.pxd``
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user