From b5c8430900b0418ad33cd8366b518556f516a0cb8adf252866fc58c63fa96528 Mon Sep 17 00:00:00 2001 From: Matej Cepl Date: Fri, 20 Jan 2023 16:02:18 +0000 Subject: [PATCH 1/2] - Add close_file_before_test.patch, to make sure the testing data are flushed to the file (bsc#1206555). OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-lxml?expand=0&rev=170 --- close_file_before_test.patch | 15 +++++++++++++++ python-lxml.changes | 6 ++++++ python-lxml.spec | 6 +++++- 3 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 close_file_before_test.patch diff --git a/close_file_before_test.patch b/close_file_before_test.patch new file mode 100644 index 0000000..b64ded9 --- /dev/null +++ b/close_file_before_test.patch @@ -0,0 +1,15 @@ +--- + src/lxml/tests/test_etree.py | 2 ++ + 1 file changed, 2 insertions(+) + +--- a/src/lxml/tests/test_etree.py ++++ b/src/lxml/tests/test_etree.py +@@ -5278,6 +5278,8 @@ class ETreeWriteTestCase(HelperTestCase) + tree = self.parse(_bytes(''+''*200+'')) + with tmpfile() as filename: + tree.write(filename, compression=9) ++ os.fsync(filename[0]) ++ os.lseek(filename[0], 0, os.SEEK_SET) + data = etree.tostring(etree.parse(filename)) + self.assertEqual(_bytes(''+''*200+''), + data) diff --git a/python-lxml.changes b/python-lxml.changes index 054a397..f259469 100644 --- a/python-lxml.changes +++ b/python-lxml.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Fri Jan 20 16:00:15 UTC 2023 - Matej Cepl + +- Add close_file_before_test.patch, to make sure the testing data + are flushed to the file (bsc#1206555). + ------------------------------------------------------------------- Thu Dec 29 07:46:19 UTC 2022 - Torsten Gruner diff --git a/python-lxml.spec b/python-lxml.spec index f53309a..950d21a 100644 --- a/python-lxml.spec +++ b/python-lxml.spec @@ -26,6 +26,9 @@ URL: https://lxml.de/ Source0: https://files.pythonhosted.org/packages/source/l/lxml/lxml-%{version}.tar.gz Source1: https://lxml.de/lxmldoc-4.5.2.pdf Source99: python-lxml.rpmlintrc +# PATCH-FIX-UPSTREAM close_file_before_test.patch bsc#1206555 mcepl@suse.com +# make sure the testing data are flushed to the file +Patch0: close_file_before_test.patch BuildRequires: %{python_module Cython >= 0.29.7} BuildRequires: %{python_module base} BuildRequires: %{python_module cssselect >= 0.9.1} @@ -70,7 +73,8 @@ RelaxNG, XML Schema, XSLT and C14N. This package contains header files needed to use lxml's C API. %prep -%setup -q -n lxml-%{version} +%autosetup -p1 -n lxml-%{version} + cp %{SOURCE1} . # remove generated files From 931131b80715207b61a8fad85b8958ff8778c19ae2b5d0f4dfd70dc4f9daa30b Mon Sep 17 00:00:00 2001 From: Matej Cepl Date: Sun, 22 Jan 2023 04:02:39 +0000 Subject: [PATCH 2/2] Update version of the patch. OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-lxml?expand=0&rev=171 --- close_file_before_test.patch | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/close_file_before_test.patch b/close_file_before_test.patch index b64ded9..c50bdfe 100644 --- a/close_file_before_test.patch +++ b/close_file_before_test.patch @@ -1,15 +1,29 @@ --- - src/lxml/tests/test_etree.py | 2 ++ - 1 file changed, 2 insertions(+) + src/lxml/tests/test_etree.py | 9 ++++++--- + 1 file changed, 6 insertions(+), 3 deletions(-) --- a/src/lxml/tests/test_etree.py +++ b/src/lxml/tests/test_etree.py -@@ -5278,6 +5278,8 @@ class ETreeWriteTestCase(HelperTestCase) +@@ -18,6 +18,7 @@ import re + import gc + import operator + import textwrap ++import tempfile + import zlib + import gzip + +@@ -5276,9 +5277,11 @@ class ETreeWriteTestCase(HelperTestCase) + + def test_write_file_gzip_parse(self): tree = self.parse(_bytes(''+''*200+'')) - with tmpfile() as filename: - tree.write(filename, compression=9) -+ os.fsync(filename[0]) -+ os.lseek(filename[0], 0, os.SEEK_SET) - data = etree.tostring(etree.parse(filename)) +- with tmpfile() as filename: +- tree.write(filename, compression=9) +- data = etree.tostring(etree.parse(filename)) ++ with tempfile.NamedTemporaryFile() as f: ++ tree.write(f.name, compression=9) ++ f.file.flush() ++ f.file.seek(0) ++ data = etree.tostring(etree.parse(f.name)) self.assertEqual(_bytes(''+''*200+''), data) +