From 130ce8ede806e32a7288deebea352bbe240e0a225b592295baa144fb5cd482f5 Mon Sep 17 00:00:00 2001 From: Matej Cepl Date: Fri, 11 Oct 2019 15:22:37 +0000 Subject: [PATCH] Accepting request 737542 from home:mcepl:branches:devel:languages:python - Add fix_tests_38.patch to overcome failing test_writers.test_odt.DocutilsOdtTestCase with Python 3.8. Also, failed as shp#docutils#161. OBS-URL: https://build.opensuse.org/request/show/737542 OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-docutils?expand=0&rev=59 --- fix_tests_38.patch | 34 +++++++++++++++++++++++++++++++--- python-docutils.changes | 5 +++-- python-docutils.spec | 2 ++ 3 files changed, 36 insertions(+), 5 deletions(-) diff --git a/fix_tests_38.patch b/fix_tests_38.patch index b746387..f724eec 100644 --- a/fix_tests_38.patch +++ b/fix_tests_38.patch @@ -1,12 +1,40 @@ --- a/test/test_writers/test_odt.py +++ b/test/test_writers/test_odt.py -@@ -114,7 +114,8 @@ class DocutilsOdtTestCase(DocutilsTestSu +@@ -80,7 +80,7 @@ class DocutilsOdtTestCase(DocutilsTestSu + sys.stderr.write(s1) + return WhichElementTree + +- def process_test(self, input_filename, expected_filename, ++ def process_test(self, input_filename, expected_filename, + save_output_name=None, settings_overrides=None): + if not self.check_import(): + return +@@ -112,19 +112,22 @@ class DocutilsOdtTestCase(DocutilsTestSu + outfile.close() + content1 = self.extract_file(result, 'content.xml') content2 = self.extract_file(expected, 'content.xml') - msg = 'content.xml not equal: expected len: %d actual len: %d' % ( - len(content2), len(content1), ) +- msg = 'content.xml not equal: expected len: %d actual len: %d' % ( +- len(content2), len(content1), ) - self.assertEqual(content1, content2, msg) + # self.assertEqual(content1, content2, msg) + self.assertEqual(content1, content2) def extract_file(self, payload, filename): ++ from xml.etree import ElementTree as etree payloadfile = BytesIO() + payloadfile.write(payload) + payloadfile.seek(0) + zfile = zipfile.ZipFile(payloadfile, 'r') + content1 = zfile.read(filename) +- doc = minidom.parseString(content1) +- #content2 = doc.toprettyxml(indent=' ') +- content2 = doc.toxml() ++ if hasattr(etree, 'canonicalize'): ++ content2 = etree.canonicalize(content1, with_comments=True) ++ else: ++ #content2 = doc.toprettyxml(indent=' ') ++ doc = minidom.parseString(content1) ++ content2 = doc.toxml() + return content2 + + def assertEqual(self, first, second, msg=None): diff --git a/python-docutils.changes b/python-docutils.changes index 47679c6..192d94b 100644 --- a/python-docutils.changes +++ b/python-docutils.changes @@ -1,8 +1,9 @@ ------------------------------------------------------------------- Fri Oct 11 14:11:49 CEST 2019 - Matej Cepl -- Add fix_tests_38.patch to overcome failing tests with Python - 3.8. +- Add fix_tests_38.patch to overcome failing + test_writers.test_odt.DocutilsOdtTestCase with Python 3.8. + Also, failed as shp#docutils#161. ------------------------------------------------------------------- Sat Sep 14 01:50:36 UTC 2019 - John Vandenberg diff --git a/python-docutils.spec b/python-docutils.spec index 83b9a58..6117844 100644 --- a/python-docutils.spec +++ b/python-docutils.spec @@ -34,6 +34,8 @@ Group: Development/Languages/Python URL: https://pypi.python.org/pypi/docutils/ Source: https://files.pythonhosted.org/packages/source/d/docutils/docutils-%{version}.tar.gz Source99: python-docutils-rpmlintrc +# PATCH-FIX-UPSTREAM fix_tests_38.patch shp#docutils#161 mcepl@suse.com +# Fixes failing tests in test_writers.test_odt.DocutilsOdtTestCase Patch0: fix_tests_38.patch BuildRequires: %{python_module setuptools} BuildRequires: %{python_module xml}