From a646dc083c3c92b6f790ae347cb34614fe3613ec9f10e5e9692b9c4f7e558bec Mon Sep 17 00:00:00 2001 From: Matej Cepl Date: Mon, 9 Nov 2020 15:50:31 +0000 Subject: [PATCH 1/5] - Update to 1.3.0: - Drop support for Python 3.5 - Add XmlDocument and Wsdl11Document classes - Refactoring of XMLResource to support ElementTree-like XPath API on both full and lazy modes - Remove skip_network_tests.patch OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-xmlschema?expand=0&rev=20 --- python-xmlschema.changes | 10 ++++++++++ python-xmlschema.spec | 20 ++++++++++++-------- skip_network_tests.patch | 10 ---------- xmlschema-1.2.5.tar.gz | 3 --- xmlschema-1.3.0.tar.gz | 3 +++ 5 files changed, 25 insertions(+), 21 deletions(-) delete mode 100644 skip_network_tests.patch delete mode 100644 xmlschema-1.2.5.tar.gz create mode 100644 xmlschema-1.3.0.tar.gz diff --git a/python-xmlschema.changes b/python-xmlschema.changes index 0c10653..824939e 100644 --- a/python-xmlschema.changes +++ b/python-xmlschema.changes @@ -1,3 +1,13 @@ +------------------------------------------------------------------- +Mon Nov 9 15:32:59 UTC 2020 - Matej Cepl + +- Update to 1.3.0: + - Drop support for Python 3.5 + - Add XmlDocument and Wsdl11Document classes + - Refactoring of XMLResource to support ElementTree-like XPath + API on both full and lazy modes +- Remove skip_network_tests.patch + ------------------------------------------------------------------- Sun Oct 11 16:18:52 UTC 2020 - Matej Cepl diff --git a/python-xmlschema.spec b/python-xmlschema.spec index 80047a1..76809dd 100644 --- a/python-xmlschema.spec +++ b/python-xmlschema.spec @@ -19,17 +19,15 @@ %{?!python_module:%define python_module() python-%{**} python3-%{**}} %define skip_python2 1 Name: python-xmlschema -Version: 1.2.5 +Version: 1.3.0 Release: 0 Summary: An XML Schema validator and decoder License: MIT -URL: https://github.com/brunato/xmlschema +URL: https://github.com/sissaschool/xmlschema Source: https://files.pythonhosted.org/packages/source/x/xmlschema/xmlschema-%{version}.tar.gz -# PATCH-FIX-UPSTREAM skip_network_tests.patch gh#sissaschool/xmlschema#206 mcepl@suse.com -# Just skip test_export_remote__issue_187 test when not connected to the network. -Patch0: skip_network_tests.patch BuildRequires: %{python_module elementpath >= 1.4.0} BuildRequires: %{python_module lxml} +BuildRequires: %{python_module pip} BuildRequires: %{python_module pytest} BuildRequires: %{python_module setuptools} BuildRequires: fdupes @@ -54,6 +52,8 @@ sed -i -e 's:~=:>=:' setup.py rm tests/check_memory.py rm tests/test_memory.py +sed -i -e '1s@/usr/bin/env python@/usr/bin/python@' xmlschema/testing/builders.py + %build export LANG="en_US.UTF8" %python_build @@ -68,10 +68,14 @@ for p in json2xml validate xml2json; do done %check -# test_element_tree_import_script is (easily workaroundable) https://github.com/sissaschool/xmlschema/issues/167 -# tests_factory setup is broken export LANG="en_US.UTF8" -%pytest -k "not (test_element_tree_import_script or tests_factory)" tests +# test_element_tree_import_script is (easily workaroundable) gh#sissaschool/xmlschema#167 +# tests_factory setup is broken +SKIP_TESTS="test_element_tree_import_script or tests_factory" +# gh#sissaschool/xmlschema#210 +SKIP_TESTS="$SKIP_TESTS or test_imported_element_tree or test_xml_resource_defuse" +SKIP_TESTS="$SKIP_TESTS or test_xml_resource_from_string" +%pytest -k "not ($SKIP_TESTS)" tests %post %python_install_alternative xmlschema-json2xml diff --git a/skip_network_tests.patch b/skip_network_tests.patch deleted file mode 100644 index 66fc5e0..0000000 --- a/skip_network_tests.patch +++ /dev/null @@ -1,10 +0,0 @@ ---- a/tests/validators/test_schema_class.py -+++ b/tests/validators/test_schema_class.py -@@ -261,6 +261,7 @@ class TestXMLSchema10(XsdValidatorTestCa - - self.assertFalse(os.path.isdir(dirname)) - -+ @unittest.skipIf(SKIP_REMOTE_TESTS, "Remote networks are not accessible.") - def test_export_remote__issue_187(self): - vh_schema_file = self.casepath('issues/issue_187/issue_187_2.xsd') - vh_schema = self.schema_class(vh_schema_file) diff --git a/xmlschema-1.2.5.tar.gz b/xmlschema-1.2.5.tar.gz deleted file mode 100644 index 8e461b0..0000000 --- a/xmlschema-1.2.5.tar.gz +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:1c4515dd16b5b556dac27cae70bdb3c863e1448e9d58896326ff468ff55e4246 -size 290750 diff --git a/xmlschema-1.3.0.tar.gz b/xmlschema-1.3.0.tar.gz new file mode 100644 index 0000000..d578b85 --- /dev/null +++ b/xmlschema-1.3.0.tar.gz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:638eddd3150b8214397eddeb9402457678b63a343c468a96042f56438b6ff1d8 +size 319713 From 89a32e9a2c77faf87811390acc541e94269a6fcd473da910254e4cafbd2ee221 Mon Sep 17 00:00:00 2001 From: Matej Cepl Date: Mon, 9 Nov 2020 19:32:34 +0000 Subject: [PATCH 2/5] - Add patches - factory_tests.patch rename tests_factory to tests so it is not recognized by pytest - remove_shebang.patch just cleaning superfluous shebang - location_testing_script.patch use actual Python executable OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-xmlschema?expand=0&rev=21 --- factory_tests.patch | 117 ++++++++++++++++++++++++++++++++++ location_testing_script.patch | 23 +++++++ python-xmlschema.changes | 5 ++ python-xmlschema.spec | 17 +++-- remove_shebang.patch | 8 +++ 5 files changed, 165 insertions(+), 5 deletions(-) create mode 100644 factory_tests.patch create mode 100644 location_testing_script.patch create mode 100644 remove_shebang.patch diff --git a/factory_tests.patch b/factory_tests.patch new file mode 100644 index 0000000..c6f42b7 --- /dev/null +++ b/factory_tests.patch @@ -0,0 +1,117 @@ +--- a/tests/test_all.py ++++ b/tests/test_all.py +@@ -13,7 +13,7 @@ if __name__ == '__main__': + import os + import platform + +- from xmlschema.testing import tests_factory, make_schema_test_class, \ ++ from xmlschema.testing import factory_tests, make_schema_test_class, \ + make_validation_test_class, get_test_program_args_parser + + DEFAULT_TESTFILES = os.path.join(os.path.dirname(__file__), 'test_cases/testfiles') +@@ -46,7 +46,7 @@ if __name__ == '__main__': + + args = get_test_program_args_parser(DEFAULT_TESTFILES).parse_args() + +- schema_tests = tests_factory( ++ schema_tests = factory_tests( + test_class_builder=make_schema_test_class, + testfiles=args.testfiles, + suffix='xsd', +@@ -54,7 +54,7 @@ if __name__ == '__main__': + ) + globals().update(schema_tests) + +- validation_tests = tests_factory( ++ validation_tests = factory_tests( + test_class_builder=make_validation_test_class, + testfiles=args.testfiles, + suffix='xml', +--- a/tests/test_schemas.py ++++ b/tests/test_schemas.py +@@ -13,7 +13,7 @@ + import os + + from xmlschema.testing import get_test_program_args_parser, \ +- tests_factory, make_schema_test_class ++ factory_tests, make_schema_test_class + + DEFAULT_TESTFILES = os.path.join(os.path.dirname(__file__), 'test_cases/testfiles') + +@@ -24,7 +24,7 @@ if __name__ == '__main__': + + args = get_test_program_args_parser(DEFAULT_TESTFILES).parse_args() + +- schema_tests = tests_factory( ++ schema_tests = factory_tests( + test_class_builder=make_schema_test_class, + testfiles=args.testfiles, + suffix='xsd', +@@ -47,7 +47,7 @@ if __name__ == '__main__': + catchbreak=args.catchbreak, buffer=args.buffer) + else: + # Creates schema tests from XSD files +- globals().update(tests_factory( ++ globals().update(factory_tests( + test_class_builder=make_schema_test_class, + suffix='xsd', + testfiles=DEFAULT_TESTFILES +--- a/tests/test_validation.py ++++ b/tests/test_validation.py +@@ -13,7 +13,7 @@ + import os + + from xmlschema.testing import get_test_program_args_parser, \ +- tests_factory, make_validation_test_class ++ factory_tests, make_validation_test_class + + DEFAULT_TESTFILES = os.path.join(os.path.dirname(__file__), 'test_cases/testfiles') + +@@ -24,7 +24,7 @@ if __name__ == '__main__': + + args = get_test_program_args_parser(DEFAULT_TESTFILES).parse_args() + +- validation_tests = tests_factory( ++ validation_tests = factory_tests( + test_class_builder=make_validation_test_class, + testfiles=args.testfiles, + suffix='xml', +@@ -47,7 +47,7 @@ if __name__ == '__main__': + catchbreak=args.catchbreak, buffer=args.buffer) + else: + # Creates schema tests from XSD files +- globals().update(tests_factory( ++ globals().update(factory_tests( + test_class_builder=make_validation_test_class, + suffix='xml', + testfiles=DEFAULT_TESTFILES +--- a/xmlschema/testing/__init__.py ++++ b/xmlschema/testing/__init__.py +@@ -23,7 +23,7 @@ from urllib.error import URLError + from .case_class import XsdValidatorTestCase + from .builders import make_schema_test_class, make_validation_test_class + from .factory import get_test_args, xsd_version_number, defuse_data, \ +- get_test_program_args_parser, get_test_line_args_parser, tests_factory ++ get_test_program_args_parser, get_test_line_args_parser, factory_tests + from .observers import SchemaObserver, ObservedXMLSchema10, ObservedXMLSchema11 + + +@@ -46,6 +46,6 @@ SKIP_REMOTE_TESTS = not has_network_acce + __all__ = [ + 'XsdValidatorTestCase', 'make_schema_test_class', 'make_validation_test_class', + 'get_test_args', 'xsd_version_number', 'defuse_data', 'get_test_program_args_parser', +- 'get_test_line_args_parser', 'tests_factory', 'SchemaObserver', 'ObservedXMLSchema10', ++ 'get_test_line_args_parser', 'factory_tests', 'SchemaObserver', 'ObservedXMLSchema10', + 'ObservedXMLSchema11', 'has_network_access', 'SKIP_REMOTE_TESTS', + ] +--- a/xmlschema/testing/factory.py ++++ b/xmlschema/testing/factory.py +@@ -117,7 +117,7 @@ def get_test_line_args_parser(): + return parser + + +-def tests_factory(test_class_builder, testfiles, suffix, check_with_lxml=False): ++def factory_tests(test_class_builder, testfiles, suffix, check_with_lxml=False): + """ + Factory function for file based schema/validation cases. + diff --git a/location_testing_script.patch b/location_testing_script.patch new file mode 100644 index 0000000..ddc2c38 --- /dev/null +++ b/location_testing_script.patch @@ -0,0 +1,23 @@ +--- + tests/test_etree_import.py | 3 +-- + 1 file changed, 1 insertion(+), 2 deletions(-) + +--- a/tests/test_etree_import.py ++++ b/tests/test_etree_import.py +@@ -15,7 +15,6 @@ import importlib + import subprocess + import platform + +- + def is_element_tree_imported(): + return '_elementtree' in sys.modules or 'xml.etree.ElementTree' in sys.modules + +@@ -42,7 +41,7 @@ class TestElementTreeImport(unittest.Tes + def test_element_tree_import_script(self): + test_dir = os.path.dirname(__file__) or '.' + +- cmd = [os.path.join(test_dir, 'check_etree_import.py')] ++ cmd = [sys.executable, os.path.join(test_dir, 'check_etree_import.py')] + process = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + + stderr = process.stderr.decode('utf-8') diff --git a/python-xmlschema.changes b/python-xmlschema.changes index 824939e..b11dd69 100644 --- a/python-xmlschema.changes +++ b/python-xmlschema.changes @@ -7,6 +7,11 @@ Mon Nov 9 15:32:59 UTC 2020 - Matej Cepl - Refactoring of XMLResource to support ElementTree-like XPath API on both full and lazy modes - Remove skip_network_tests.patch +- Add patches + - factory_tests.patch rename tests_factory to tests so it is + not recognized by pytest + - remove_shebang.patch just cleaning superfluous shebang + - location_testing_script.patch use actual Python executable ------------------------------------------------------------------- Sun Oct 11 16:18:52 UTC 2020 - Matej Cepl diff --git a/python-xmlschema.spec b/python-xmlschema.spec index 76809dd..f7cc7a6 100644 --- a/python-xmlschema.spec +++ b/python-xmlschema.spec @@ -25,6 +25,15 @@ Summary: An XML Schema validator and decoder License: MIT URL: https://github.com/sissaschool/xmlschema Source: https://files.pythonhosted.org/packages/source/x/xmlschema/xmlschema-%{version}.tar.gz +# PATCH-FIX-UPSTREAM factory_tests.patch gh#sissaschool/xmlschema#210 mcepl@suse.com +# rename tests_factory to factory_tests so it is not discovered by pytest. +Patch0: factory_tests.patch +# PATCH-FIX-UPSTREAM remove_shebang.patch gh#sissaschool/xmlschema#210 mcepl@suse.com +# Remove superfluous shebang +Patch1: remove_shebang.patch +# PATCH-FIX-UPSTREAM location_testing_script.patch gh#sissaschool/xmlschema#210 mcepl@suse.com +# this patch makes things totally awesome +Patch2: location_testing_script.patch BuildRequires: %{python_module elementpath >= 1.4.0} BuildRequires: %{python_module lxml} BuildRequires: %{python_module pip} @@ -52,8 +61,6 @@ sed -i -e 's:~=:>=:' setup.py rm tests/check_memory.py rm tests/test_memory.py -sed -i -e '1s@/usr/bin/env python@/usr/bin/python@' xmlschema/testing/builders.py - %build export LANG="en_US.UTF8" %python_build @@ -71,11 +78,11 @@ done export LANG="en_US.UTF8" # test_element_tree_import_script is (easily workaroundable) gh#sissaschool/xmlschema#167 # tests_factory setup is broken -SKIP_TESTS="test_element_tree_import_script or tests_factory" +# SKIP_TESTS="test_element_tree_import_script" # gh#sissaschool/xmlschema#210 -SKIP_TESTS="$SKIP_TESTS or test_imported_element_tree or test_xml_resource_defuse" +SKIP_TESTS="test_imported_element_tree or test_xml_resource_defuse" SKIP_TESTS="$SKIP_TESTS or test_xml_resource_from_string" -%pytest -k "not ($SKIP_TESTS)" tests +%pytest -s -k "not ($SKIP_TESTS)" tests %post %python_install_alternative xmlschema-json2xml diff --git a/remove_shebang.patch b/remove_shebang.patch new file mode 100644 index 0000000..81fbf6f --- /dev/null +++ b/remove_shebang.patch @@ -0,0 +1,8 @@ +--- a/xmlschema/testing/builders.py ++++ b/xmlschema/testing/builders.py +@@ -1,5 +1,3 @@ +-#!/usr/bin/env python +-# + # Copyright (c), 2016-2020, SISSA (International School for Advanced Studies). + # All rights reserved. + # This file is distributed under the terms of the MIT License. From 80adc55bafc84d50b045a0df9cc9e166e5b8fda1b9c68c7521761e0995604e51 Mon Sep 17 00:00:00 2001 From: Matej Cepl Date: Tue, 10 Nov 2020 07:14:36 +0000 Subject: [PATCH 3/5] - Add the upstream etree_import_in_tests.patch to fix gh#sissaschool/xmlschema#210. OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-xmlschema?expand=0&rev=22 --- etree_import_in_tests.patch | 648 ++++++++++++++++++++++++++++++++++++ python-xmlschema.changes | 6 + python-xmlschema.spec | 17 +- 3 files changed, 661 insertions(+), 10 deletions(-) create mode 100644 etree_import_in_tests.patch diff --git a/etree_import_in_tests.patch b/etree_import_in_tests.patch new file mode 100644 index 0000000..e7ffd34 --- /dev/null +++ b/etree_import_in_tests.patch @@ -0,0 +1,648 @@ +diff --git a/tests/test_documents.py b/tests/test_documents.py +index 6c616fe..bd5d8c5 100644 +--- a/tests/test_documents.py ++++ b/tests/test_documents.py +@@ -16,7 +16,6 @@ import io + import pathlib + import tempfile + from decimal import Decimal +-from xml.etree import ElementTree + + try: + import lxml.etree as lxml_etree +@@ -27,7 +26,7 @@ from xmlschema import XMLSchema10, XMLSchema11, XmlDocument, \ + XMLResourceError, XMLSchemaValidationError, XMLSchemaDecodeError, \ + to_json, from_json + +-from xmlschema.etree import is_etree_element, is_etree_document ++from xmlschema.etree import ElementTree, is_etree_element, is_etree_document + from xmlschema.namespaces import XSD_NAMESPACE, XSI_NAMESPACE + from xmlschema.resources import XMLResource + from xmlschema.documents import get_context +diff --git a/tests/test_etree.py b/tests/test_etree.py +index d16c793..96aba4b 100644 +--- a/tests/test_etree.py ++++ b/tests/test_etree.py +@@ -11,10 +11,11 @@ + import unittest + import os + import platform +-from xml.etree import ElementTree + import lxml.etree + +-from xmlschema import etree ++from xmlschema.etree import ElementTree, PyElementTree, ParseError, \ ++ SafeXMLParser, etree_tostring, etree_getpath, etree_iter_location_hints, \ ++ etree_iterpath, etree_elements_assert_equal, prune_etree + + TEST_CASES_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'test_cases/') + +@@ -25,176 +26,173 @@ def casepath(relative_path): + + class TestElementTree(unittest.TestCase): + +- def test_imported_element_tree(self): +- self.assertIs(ElementTree, etree.ElementTree) +- + def test_element_string_serialization(self): +- self.assertRaises(TypeError, etree.etree_tostring, '') ++ self.assertRaises(TypeError, etree_tostring, '') + + elem = ElementTree.Element('element') +- self.assertEqual(etree.etree_tostring(elem), '') +- self.assertEqual(etree.etree_tostring(elem, xml_declaration=True), '') ++ self.assertEqual(etree_tostring(elem), '') ++ self.assertEqual(etree_tostring(elem, xml_declaration=True), '') + +- self.assertEqual(etree.etree_tostring(elem, encoding='us-ascii'), b'') +- self.assertEqual(etree.etree_tostring(elem, encoding='us-ascii', indent=' '), ++ self.assertEqual(etree_tostring(elem, encoding='us-ascii'), b'') ++ self.assertEqual(etree_tostring(elem, encoding='us-ascii', indent=' '), + b' ') +- self.assertEqual(etree.etree_tostring(elem, encoding='us-ascii', xml_declaration=True), ++ self.assertEqual(etree_tostring(elem, encoding='us-ascii', xml_declaration=True), + b'\n') + +- self.assertEqual(etree.etree_tostring(elem, encoding='ascii'), ++ self.assertEqual(etree_tostring(elem, encoding='ascii'), + b"\n") +- self.assertEqual(etree.etree_tostring(elem, encoding='ascii', xml_declaration=False), ++ self.assertEqual(etree_tostring(elem, encoding='ascii', xml_declaration=False), + b'') +- self.assertEqual(etree.etree_tostring(elem, encoding='utf-8'), b'') +- self.assertEqual(etree.etree_tostring(elem, encoding='utf-8', xml_declaration=True), ++ self.assertEqual(etree_tostring(elem, encoding='utf-8'), b'') ++ self.assertEqual(etree_tostring(elem, encoding='utf-8', xml_declaration=True), + b'\n') + +- self.assertEqual(etree.etree_tostring(elem, encoding='iso-8859-1'), ++ self.assertEqual(etree_tostring(elem, encoding='iso-8859-1'), + b"\n") +- self.assertEqual(etree.etree_tostring(elem, encoding='iso-8859-1', xml_declaration=False), ++ self.assertEqual(etree_tostring(elem, encoding='iso-8859-1', xml_declaration=False), + b"") + +- self.assertEqual(etree.etree_tostring(elem, method='html'), '') +- self.assertEqual(etree.etree_tostring(elem, method='text'), '') ++ self.assertEqual(etree_tostring(elem, method='html'), '') ++ self.assertEqual(etree_tostring(elem, method='text'), '') + +- root = etree.ElementTree.XML('\n' +- ' text1\n' +- ' text2\n' +- '') +- self.assertEqual(etree.etree_tostring(root, method='text'), '\n text1\n text2') ++ root = ElementTree.XML('\n' ++ ' text1\n' ++ ' text2\n' ++ '') ++ self.assertEqual(etree_tostring(root, method='text'), '\n text1\n text2') + + def test_py_element_string_serialization(self): +- elem = etree.PyElementTree.Element('element') +- self.assertEqual(etree.etree_tostring(elem), '') +- self.assertEqual(etree.etree_tostring(elem, xml_declaration=True), '') ++ elem = PyElementTree.Element('element') ++ self.assertEqual(etree_tostring(elem), '') ++ self.assertEqual(etree_tostring(elem, xml_declaration=True), '') + +- self.assertEqual(etree.etree_tostring(elem, encoding='us-ascii'), b'') +- self.assertEqual(etree.etree_tostring(elem, encoding='us-ascii', xml_declaration=True), ++ self.assertEqual(etree_tostring(elem, encoding='us-ascii'), b'') ++ self.assertEqual(etree_tostring(elem, encoding='us-ascii', xml_declaration=True), + b'\n') + +- self.assertEqual(etree.etree_tostring(elem, encoding='ascii'), ++ self.assertEqual(etree_tostring(elem, encoding='ascii'), + b"\n") +- self.assertEqual(etree.etree_tostring(elem, encoding='ascii', xml_declaration=False), ++ self.assertEqual(etree_tostring(elem, encoding='ascii', xml_declaration=False), + b'') +- self.assertEqual(etree.etree_tostring(elem, encoding='utf-8'), b'') +- self.assertEqual(etree.etree_tostring(elem, encoding='utf-8', xml_declaration=True), ++ self.assertEqual(etree_tostring(elem, encoding='utf-8'), b'') ++ self.assertEqual(etree_tostring(elem, encoding='utf-8', xml_declaration=True), + b'\n') + +- self.assertEqual(etree.etree_tostring(elem, encoding='iso-8859-1'), ++ self.assertEqual(etree_tostring(elem, encoding='iso-8859-1'), + b"\n") +- self.assertEqual(etree.etree_tostring(elem, encoding='iso-8859-1', xml_declaration=False), ++ self.assertEqual(etree_tostring(elem, encoding='iso-8859-1', xml_declaration=False), + b"") + +- self.assertEqual(etree.etree_tostring(elem, method='html'), '') +- self.assertEqual(etree.etree_tostring(elem, method='text'), '') ++ self.assertEqual(etree_tostring(elem, method='html'), '') ++ self.assertEqual(etree_tostring(elem, method='text'), '') + +- root = etree.PyElementTree.XML('\n' +- ' text1\n' +- ' text2\n' +- '') +- self.assertEqual(etree.etree_tostring(root, method='text'), '\n text1\n text2') ++ root = PyElementTree.XML('\n' ++ ' text1\n' ++ ' text2\n' ++ '') ++ self.assertEqual(etree_tostring(root, method='text'), '\n text1\n text2') + + def test_lxml_element_string_serialization(self): + elem = lxml.etree.Element('element') +- self.assertEqual(etree.etree_tostring(elem), '') +- self.assertEqual(etree.etree_tostring(elem, xml_declaration=True), '') ++ self.assertEqual(etree_tostring(elem), '') ++ self.assertEqual(etree_tostring(elem, xml_declaration=True), '') + +- self.assertEqual(etree.etree_tostring(elem, encoding='us-ascii'), b'') +- self.assertEqual(etree.etree_tostring(elem, encoding='us-ascii', xml_declaration=True), ++ self.assertEqual(etree_tostring(elem, encoding='us-ascii'), b'') ++ self.assertEqual(etree_tostring(elem, encoding='us-ascii', xml_declaration=True), + b'\n') + +- self.assertEqual(etree.etree_tostring(elem, encoding='ascii'), b'') +- self.assertEqual(etree.etree_tostring(elem, encoding='ascii', xml_declaration=True), ++ self.assertEqual(etree_tostring(elem, encoding='ascii'), b'') ++ self.assertEqual(etree_tostring(elem, encoding='ascii', xml_declaration=True), + b'\n') + +- self.assertEqual(etree.etree_tostring(elem, encoding='utf-8'), b'') +- self.assertEqual(etree.etree_tostring(elem, encoding='utf-8', xml_declaration=True), ++ self.assertEqual(etree_tostring(elem, encoding='utf-8'), b'') ++ self.assertEqual(etree_tostring(elem, encoding='utf-8', xml_declaration=True), + b'\n') + +- self.assertEqual(etree.etree_tostring(elem, encoding='iso-8859-1'), ++ self.assertEqual(etree_tostring(elem, encoding='iso-8859-1'), + b"\n") +- self.assertEqual(etree.etree_tostring(elem, encoding='iso-8859-1', xml_declaration=False), ++ self.assertEqual(etree_tostring(elem, encoding='iso-8859-1', xml_declaration=False), + b"") + +- self.assertEqual(etree.etree_tostring(elem, method='html'), '') +- self.assertEqual(etree.etree_tostring(elem, method='text'), '') ++ self.assertEqual(etree_tostring(elem, method='html'), '') ++ self.assertEqual(etree_tostring(elem, method='text'), '') + + root = lxml.etree.XML('\n' + ' text1\n' + ' text2\n' + '') +- self.assertEqual(etree.etree_tostring(root, method='text'), '\n text1\n text2') ++ self.assertEqual(etree_tostring(root, method='text'), '\n text1\n text2') + + def test_defuse_xml_entities(self): + xml_file = casepath('resources/with_entity.xml') + +- elem = etree.ElementTree.parse(xml_file).getroot() ++ elem = ElementTree.parse(xml_file).getroot() + self.assertEqual(elem.text, 'abc') + +- parser = etree.SafeXMLParser(target=etree.PyElementTree.TreeBuilder()) +- with self.assertRaises(etree.PyElementTree.ParseError) as ctx: +- etree.ElementTree.parse(xml_file, parser=parser) ++ parser = SafeXMLParser(target=PyElementTree.TreeBuilder()) ++ with self.assertRaises(PyElementTree.ParseError) as ctx: ++ ElementTree.parse(xml_file, parser=parser) + self.assertEqual("Entities are forbidden (entity_name='e')", str(ctx.exception)) + + def test_defuse_xml_external_entities(self): + xml_file = casepath('resources/external_entity.xml') + +- with self.assertRaises(etree.ParseError) as ctx: +- etree.ElementTree.parse(xml_file) ++ with self.assertRaises(ParseError) as ctx: ++ ElementTree.parse(xml_file) + self.assertIn("undefined entity &ee", str(ctx.exception)) + +- parser = etree.SafeXMLParser(target=etree.PyElementTree.TreeBuilder()) +- with self.assertRaises(etree.PyElementTree.ParseError) as ctx: +- etree.ElementTree.parse(xml_file, parser=parser) ++ parser = SafeXMLParser(target=PyElementTree.TreeBuilder()) ++ with self.assertRaises(PyElementTree.ParseError) as ctx: ++ ElementTree.parse(xml_file, parser=parser) + self.assertEqual("Entities are forbidden (entity_name='ee')", str(ctx.exception)) + + def test_defuse_xml_unused_external_entities(self): + xml_file = casepath('resources/unused_external_entity.xml') + +- elem = etree.ElementTree.parse(xml_file).getroot() ++ elem = ElementTree.parse(xml_file).getroot() + self.assertEqual(elem.text, 'abc') + +- parser = etree.SafeXMLParser(target=etree.PyElementTree.TreeBuilder()) +- with self.assertRaises(etree.PyElementTree.ParseError) as ctx: +- etree.ElementTree.parse(xml_file, parser=parser) ++ parser = SafeXMLParser(target=PyElementTree.TreeBuilder()) ++ with self.assertRaises(PyElementTree.ParseError) as ctx: ++ ElementTree.parse(xml_file, parser=parser) + self.assertEqual("Entities are forbidden (entity_name='ee')", str(ctx.exception)) + + def test_defuse_xml_unparsed_entities(self): + xml_file = casepath('resources/unparsed_entity.xml') + +- parser = etree.SafeXMLParser(target=etree.PyElementTree.TreeBuilder()) +- with self.assertRaises(etree.PyElementTree.ParseError) as ctx: +- etree.ElementTree.parse(xml_file, parser=parser) ++ parser = SafeXMLParser(target=PyElementTree.TreeBuilder()) ++ with self.assertRaises(PyElementTree.ParseError) as ctx: ++ ElementTree.parse(xml_file, parser=parser) + self.assertEqual("Unparsed entities are forbidden (entity_name='logo_file')", + str(ctx.exception)) + + def test_defuse_xml_unused_unparsed_entities(self): + xml_file = casepath('resources/unused_unparsed_entity.xml') + +- elem = etree.ElementTree.parse(xml_file).getroot() ++ elem = ElementTree.parse(xml_file).getroot() + self.assertIsNone(elem.text) + +- parser = etree.SafeXMLParser(target=etree.PyElementTree.TreeBuilder()) +- with self.assertRaises(etree.PyElementTree.ParseError) as ctx: +- etree.ElementTree.parse(xml_file, parser=parser) ++ parser = SafeXMLParser(target=PyElementTree.TreeBuilder()) ++ with self.assertRaises(PyElementTree.ParseError) as ctx: ++ ElementTree.parse(xml_file, parser=parser) + self.assertEqual("Unparsed entities are forbidden (entity_name='logo_file')", + str(ctx.exception)) + + def test_etree_iterpath(self): + root = ElementTree.XML('') + +- items = list(etree.etree_iterpath(root)) ++ items = list(etree_iterpath(root)) + self.assertListEqual(items, [ + (root, '.'), (root[0], './b1'), (root[0][0], './b1/c1'), + (root[0][1], './b1/c2'), (root[1], './b2'), (root[2], './b3'), + (root[2][0], './b3/c3') + ]) + +- self.assertListEqual(items, list(etree.etree_iterpath(root, tag='*'))) +- self.assertListEqual(items, list(etree.etree_iterpath(root, path=''))) +- self.assertListEqual(items, list(etree.etree_iterpath(root, path=None))) ++ self.assertListEqual(items, list(etree_iterpath(root, tag='*'))) ++ self.assertListEqual(items, list(etree_iterpath(root, path=''))) ++ self.assertListEqual(items, list(etree_iterpath(root, path=None))) + +- self.assertListEqual(list(etree.etree_iterpath(root, path='/')), [ ++ self.assertListEqual(list(etree_iterpath(root, path='/')), [ + (root, '/'), (root[0], '/b1'), (root[0][0], '/b1/c1'), + (root[0][1], '/b1/c2'), (root[1], '/b2'), (root[2], '/b3'), + (root[2][0], '/b3/c3') +@@ -203,104 +201,104 @@ class TestElementTree(unittest.TestCase): + def test_etree_getpath(self): + root = ElementTree.XML('') + +- self.assertEqual(etree.etree_getpath(root, root), '.') +- self.assertEqual(etree.etree_getpath(root[0], root), './b1') +- self.assertEqual(etree.etree_getpath(root[2][0], root), './b3/c3') +- self.assertEqual(etree.etree_getpath(root[0], root, parent_path=True), '.') +- self.assertEqual(etree.etree_getpath(root[2][0], root, parent_path=True), './b3') ++ self.assertEqual(etree_getpath(root, root), '.') ++ self.assertEqual(etree_getpath(root[0], root), './b1') ++ self.assertEqual(etree_getpath(root[2][0], root), './b3/c3') ++ self.assertEqual(etree_getpath(root[0], root, parent_path=True), '.') ++ self.assertEqual(etree_getpath(root[2][0], root, parent_path=True), './b3') + +- self.assertIsNone(etree.etree_getpath(root, root[0])) +- self.assertIsNone(etree.etree_getpath(root[0], root[1])) +- self.assertIsNone(etree.etree_getpath(root, root, parent_path=True)) ++ self.assertIsNone(etree_getpath(root, root[0])) ++ self.assertIsNone(etree_getpath(root[0], root[1])) ++ self.assertIsNone(etree_getpath(root, root, parent_path=True)) + + def test_etree_elements_assert_equal(self): + e1 = ElementTree.XML('text\n\n') + e2 = ElementTree.XML('text\n\n') + +- self.assertIsNone(etree.etree_elements_assert_equal(e1, e1)) +- self.assertIsNone(etree.etree_elements_assert_equal(e1, e2)) ++ self.assertIsNone(etree_elements_assert_equal(e1, e1)) ++ self.assertIsNone(etree_elements_assert_equal(e1, e2)) + + e2 = lxml.etree.XML('text\n\n') +- self.assertIsNone(etree.etree_elements_assert_equal(e1, e2)) ++ self.assertIsNone(etree_elements_assert_equal(e1, e2)) + + e2 = ElementTree.XML('text\n\n') + with self.assertRaises(AssertionError) as ctx: +- etree.etree_elements_assert_equal(e1, e2) ++ etree_elements_assert_equal(e1, e2) + self.assertIn("has lesser children than text \n\n') +- self.assertIsNone(etree.etree_elements_assert_equal(e1, e2, strict=False)) ++ self.assertIsNone(etree_elements_assert_equal(e1, e2, strict=False)) + with self.assertRaises(AssertionError) as ctx: +- etree.etree_elements_assert_equal(e1, e2) ++ etree_elements_assert_equal(e1, e2) + self.assertIn("texts differ: 'text' != 'text '", str(ctx.exception)) + + e2 = ElementTree.XML('text\ntext\n') + with self.assertRaises(AssertionError) as ctx: +- etree.etree_elements_assert_equal(e1, e2, strict=False) ++ etree_elements_assert_equal(e1, e2, strict=False) + self.assertIn("texts differ: None != 'text'", str(ctx.exception)) + + e2 = ElementTree.XML('text\n') +- self.assertIsNone(etree.etree_elements_assert_equal(e1, e2)) ++ self.assertIsNone(etree_elements_assert_equal(e1, e2)) + + e2 = ElementTree.XML('text\n') +- self.assertIsNone(etree.etree_elements_assert_equal(e1, e2, strict=False)) ++ self.assertIsNone(etree_elements_assert_equal(e1, e2, strict=False)) + with self.assertRaises(AssertionError) as ctx: +- etree.etree_elements_assert_equal(e1, e2) ++ etree_elements_assert_equal(e1, e2) + self.assertIn(r"tails differ: '\n' != None", str(ctx.exception)) + + e2 = ElementTree.XML('text\n\n') +- self.assertIsNone(etree.etree_elements_assert_equal(e1, e2, strict=False)) ++ self.assertIsNone(etree_elements_assert_equal(e1, e2, strict=False)) + with self.assertRaises(AssertionError) as ctx: +- etree.etree_elements_assert_equal(e1, e2) ++ etree_elements_assert_equal(e1, e2) + self.assertIn("attributes differ: {'a': '1'} != {'a': '1 '}", str(ctx.exception)) + + e2 = ElementTree.XML('text\n\n') + with self.assertRaises(AssertionError) as ctx: +- etree.etree_elements_assert_equal(e1, e2, strict=False) ++ etree_elements_assert_equal(e1, e2, strict=False) + self.assertIn("attribute 'a' values differ: '1' != '2'", str(ctx.exception)) + + e2 = ElementTree.XML('text\n\n') +- self.assertIsNone(etree.etree_elements_assert_equal(e1, e2)) +- self.assertIsNone(etree.etree_elements_assert_equal(e1, e2, skip_comments=False)) ++ self.assertIsNone(etree_elements_assert_equal(e1, e2)) ++ self.assertIsNone(etree_elements_assert_equal(e1, e2, skip_comments=False)) + + e2 = lxml.etree.XML('text\n\n') +- self.assertIsNone(etree.etree_elements_assert_equal(e1, e2)) ++ self.assertIsNone(etree_elements_assert_equal(e1, e2)) + + e1 = ElementTree.XML('+1') + e2 = ElementTree.XML('+ 1 ') +- self.assertIsNone(etree.etree_elements_assert_equal(e1, e2, strict=False)) ++ self.assertIsNone(etree_elements_assert_equal(e1, e2, strict=False)) + + e1 = ElementTree.XML('+1') + e2 = ElementTree.XML('+1.1 ') + + with self.assertRaises(AssertionError) as ctx: +- etree.etree_elements_assert_equal(e1, e2, strict=False) ++ etree_elements_assert_equal(e1, e2, strict=False) + self.assertIn("texts differ: '+1' != '+1.1 '", str(ctx.exception)) + + e1 = ElementTree.XML('1') + e2 = ElementTree.XML('true ') +- self.assertIsNone(etree.etree_elements_assert_equal(e1, e2, strict=False)) +- self.assertIsNone(etree.etree_elements_assert_equal(e2, e1, strict=False)) ++ self.assertIsNone(etree_elements_assert_equal(e1, e2, strict=False)) ++ self.assertIsNone(etree_elements_assert_equal(e2, e1, strict=False)) + + e2 = ElementTree.XML('false ') + with self.assertRaises(AssertionError) as ctx: +- etree.etree_elements_assert_equal(e1, e2, strict=False) ++ etree_elements_assert_equal(e1, e2, strict=False) + self.assertIn("texts differ: '1' != 'false '", str(ctx.exception)) + + e1 = ElementTree.XML(' 0') +- self.assertIsNone(etree.etree_elements_assert_equal(e1, e2, strict=False)) +- self.assertIsNone(etree.etree_elements_assert_equal(e2, e1, strict=False)) ++ self.assertIsNone(etree_elements_assert_equal(e1, e2, strict=False)) ++ self.assertIsNone(etree_elements_assert_equal(e2, e1, strict=False)) + + e2 = ElementTree.XML('true ') + with self.assertRaises(AssertionError) as ctx: +- etree.etree_elements_assert_equal(e1, e2, strict=False) ++ etree_elements_assert_equal(e1, e2, strict=False) + self.assertIn("texts differ: ' 0' != 'true '", str(ctx.exception)) + + e1 = ElementTree.XML('text\n\n') + e2 = ElementTree.XML('texttail\n\n') + + with self.assertRaises(AssertionError) as ctx: +- etree.etree_elements_assert_equal(e1, e2, strict=False) ++ etree_elements_assert_equal(e1, e2, strict=False) + self.assertIn("tails differ: None != 'tail'", str(ctx.exception)) + + def test_iter_location_hints(self): +@@ -309,7 +307,7 @@ class TestElementTree(unittest.TestCase): + xsi:schemaLocation="http://example.com/xmlschema/ns-A import-case4a.xsd"/>""" + ) + self.assertListEqual( +- list(etree.etree_iter_location_hints(elem)), ++ list(etree_iter_location_hints(elem)), + [('http://example.com/xmlschema/ns-A', 'import-case4a.xsd')] + ) + elem = ElementTree.XML( +@@ -317,16 +315,16 @@ class TestElementTree(unittest.TestCase): + xsi:noNamespaceSchemaLocation="schema.xsd"/>""" + ) + self.assertListEqual( +- list(etree.etree_iter_location_hints(elem)), [('', 'schema.xsd')] ++ list(etree_iter_location_hints(elem)), [('', 'schema.xsd')] + ) + + def test_prune_etree(self): + root = ElementTree.XML('') +- etree.prune_etree(root, selector=lambda x: x.tag == 'b1') ++ prune_etree(root, selector=lambda x: x.tag == 'b1') + self.assertListEqual([e.tag for e in root.iter()], ['a', 'b2', 'b3', 'c3']) + + root = ElementTree.XML('') +- etree.prune_etree(root, selector=lambda x: x.tag.startswith('c')) ++ prune_etree(root, selector=lambda x: x.tag.startswith('c')) + self.assertListEqual([e.tag for e in root.iter()], ['a', 'b1', 'b2', 'b3']) + + +diff --git a/tests/test_helpers.py b/tests/test_helpers.py +index a7148ca..29b93ff 100644 +--- a/tests/test_helpers.py ++++ b/tests/test_helpers.py +@@ -12,11 +12,10 @@ + import unittest + import sys + import decimal +-import xml.etree.ElementTree as ElementTree + from collections import OrderedDict + + from xmlschema import XMLSchema, XMLSchemaParseError +-from xmlschema.etree import etree_element, prune_etree ++from xmlschema.etree import ElementTree, etree_element, prune_etree + from xmlschema.qnames import XSD_SCHEMA, XSD_ELEMENT, XSD_SIMPLE_TYPE, XSD_ANNOTATION + from xmlschema.helpers import get_xsd_annotation, get_xsd_derivation_attribute, \ + get_xsd_form_attribute, raw_xml_encode, count_digits, strictly_equal, \ +diff --git a/tests/test_resources.py b/tests/test_resources.py +index 8fd2073..546bbdb 100644 +--- a/tests/test_resources.py ++++ b/tests/test_resources.py +@@ -19,7 +19,6 @@ from urllib.error import URLError + from urllib.request import urlopen + from urllib.parse import urlsplit, uses_relative + from pathlib import Path, PureWindowsPath, PurePath +-from xml.etree import ElementTree + + try: + import lxml.etree as lxml_etree +@@ -28,7 +27,7 @@ except ImportError: + + from xmlschema import fetch_namespaces, fetch_resource, normalize_url, \ + fetch_schema, fetch_schema_locations, XMLResource, XMLResourceError, XMLSchema +-from xmlschema.etree import etree_element, py_etree_element, is_etree_element ++from xmlschema.etree import ElementTree, etree_element, py_etree_element, is_etree_element + from xmlschema.namespaces import XSD_NAMESPACE + from xmlschema.resources import is_url, is_local_url, is_remote_url, \ + url_path_is_file, normalize_locations, LazySelector +diff --git a/tests/test_w3c_suite.py b/tests/test_w3c_suite.py +index 6df61d2..964ce08 100644 +--- a/tests/test_w3c_suite.py ++++ b/tests/test_w3c_suite.py +@@ -14,7 +14,6 @@ This script runs tests concerning the W3C XML Schema 1.1 test suite. + import unittest + import argparse + import os.path +-import xml.etree.ElementTree as ElementTree + import warnings + + try: +@@ -23,6 +22,7 @@ except ImportError: + lxml_etree = None + + from xmlschema import validate, XMLSchema10, XMLSchema11, XMLSchemaException ++from xmlschema.etree import ElementTree + + TEST_SUITE_NAMESPACE = "http://www.w3.org/XML/2004/xml-schema-test-suite/" + XLINK_NAMESPACE = "http://www.w3.org/1999/xlink" +diff --git a/tests/test_wsdl.py b/tests/test_wsdl.py +index c480156..65a5209 100644 +--- a/tests/test_wsdl.py ++++ b/tests/test_wsdl.py +@@ -14,13 +14,11 @@ import unittest + import os + + from xmlschema import XMLSchemaValidationError, XMLSchema10, XMLSchema11 +-from xmlschema.etree import ParseError ++from xmlschema.etree import ElementTree, ParseError + from xmlschema.wsdl import WsdlParseError, WsdlComponent, WsdlMessage, \ + WsdlPortType, WsdlOperation, WsdlBinding, WsdlService, Wsdl11Document, \ + WsdlInput, SoapHeader + +-from xml.etree import ElementTree +- + + TEST_CASES_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'test_cases/') + +diff --git a/tests/test_xpath.py b/tests/test_xpath.py +index e72b221..eb5acad 100644 +--- a/tests/test_xpath.py ++++ b/tests/test_xpath.py +@@ -12,12 +12,12 @@ + + import unittest + import os +-import xml.etree.ElementTree as ElementTree + from elementpath import XPath1Parser, XPath2Parser, Selector, \ + AttributeNode, TypedElement, ElementPathSyntaxError + + from xmlschema import XMLSchema10, XMLSchema11, XsdElement, XsdAttribute + from xmlschema.namespaces import XSD_NAMESPACE ++from xmlschema.etree import ElementTree + from xmlschema.xpath import XMLSchemaProxy, iter_schema_nodes + from xmlschema.validators import XsdAtomic, XsdAtomicRestriction + +diff --git a/tests/validation/test_decoding.py b/tests/validation/test_decoding.py +index 908e6bd..ae7742a 100644 +--- a/tests/validation/test_decoding.py ++++ b/tests/validation/test_decoding.py +@@ -12,7 +12,6 @@ import unittest + import os + from decimal import Decimal + import base64 +-from xml.etree import ElementTree + + try: + import lxml.etree as lxml_etree +@@ -24,6 +23,7 @@ import xmlschema + from xmlschema import XMLSchemaValidationError, ParkerConverter, BadgerFishConverter, \ + AbderaConverter, JsonMLConverter, ColumnarConverter + ++from xmlschema.etree import ElementTree + from xmlschema.converters import UnorderedConverter + from xmlschema.validators import XMLSchema11 + from xmlschema.testing import XsdValidatorTestCase +diff --git a/tests/validation/test_validation.py b/tests/validation/test_validation.py +index be8ce36..b104973 100644 +--- a/tests/validation/test_validation.py ++++ b/tests/validation/test_validation.py +@@ -11,7 +11,6 @@ + import unittest + import os + import sys +-from xml.etree import ElementTree + + try: + import lxml.etree as lxml_etree +@@ -21,6 +20,7 @@ except ImportError: + import xmlschema + from xmlschema import XMLSchemaValidationError + ++from xmlschema.etree import ElementTree + from xmlschema.validators import XMLSchema11 + from xmlschema.testing import XsdValidatorTestCase + +diff --git a/tests/validators/test_exceptions.py b/tests/validators/test_exceptions.py +index c23f1d6..86c5635 100644 +--- a/tests/validators/test_exceptions.py ++++ b/tests/validators/test_exceptions.py +@@ -11,10 +11,10 @@ + import unittest + import os + import io +-import xml.etree.ElementTree as ElementTree + import lxml.etree + + from xmlschema import XMLSchema, XMLResource ++from xmlschema.etree import ElementTree + from xmlschema.validators.exceptions import XMLSchemaValidatorError, \ + XMLSchemaNotBuiltError, XMLSchemaModelDepthError, XMLSchemaValidationError, \ + XMLSchemaChildrenValidationError +diff --git a/tests/validators/test_notations.py b/tests/validators/test_notations.py +index 0b48c01..a14baa8 100644 +--- a/tests/validators/test_notations.py ++++ b/tests/validators/test_notations.py +@@ -9,9 +9,9 @@ + # @author Davide Brunato + # + import unittest +-import xml.etree.ElementTree as ElementTree + + from xmlschema import XMLSchemaParseError ++from xmlschema.etree import ElementTree + from xmlschema.qnames import XSD_NOTATION + from xmlschema.validators import XMLSchema10, XMLSchema11, XsdNotation + +diff --git a/tests/validators/test_xsdbase.py b/tests/validators/test_xsdbase.py +index f5791b4..6182a83 100644 +--- a/tests/validators/test_xsdbase.py ++++ b/tests/validators/test_xsdbase.py +@@ -12,10 +12,10 @@ import unittest + import os + import platform + import re +-import xml.etree.ElementTree as ElementTree + + from xmlschema.validators import XsdValidator, XsdComponent, XMLSchema10, \ + XMLSchema11, XMLSchemaParseError, XMLSchemaValidationError, XsdGroup, XsdSimpleType ++from xmlschema.etree import ElementTree + from xmlschema.qnames import XSD_ELEMENT, XSD_ANNOTATION, XSD_ANY_TYPE + from xmlschema.namespaces import XSD_NAMESPACE + +@@ -766,7 +766,6 @@ class TestParticleMixin(unittest.TestCase): + + + if __name__ == '__main__': +- import platform + header_template = "Test xmlschema's XSD base classes with Python {} on {}" + header = header_template.format(platform.python_version(), platform.platform()) + print('{0}\n{1}\n{0}'.format("*" * len(header), header)) diff --git a/python-xmlschema.changes b/python-xmlschema.changes index b11dd69..66ba4b3 100644 --- a/python-xmlschema.changes +++ b/python-xmlschema.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Tue Nov 10 07:13:53 UTC 2020 - Matej Cepl + +- Add the upstream etree_import_in_tests.patch to fix + gh#sissaschool/xmlschema#210. + ------------------------------------------------------------------- Mon Nov 9 15:32:59 UTC 2020 - Matej Cepl diff --git a/python-xmlschema.spec b/python-xmlschema.spec index f7cc7a6..6e26ac6 100644 --- a/python-xmlschema.spec +++ b/python-xmlschema.spec @@ -25,15 +25,18 @@ Summary: An XML Schema validator and decoder License: MIT URL: https://github.com/sissaschool/xmlschema Source: https://files.pythonhosted.org/packages/source/x/xmlschema/xmlschema-%{version}.tar.gz +# PATCH-FIX-UPSTREAM etree_import_in_tests.patch gh#sissaschool/xmlschema#210 mcepl@suse.com +# use the same etree all the time +Patch0: etree_import_in_tests.patch # PATCH-FIX-UPSTREAM factory_tests.patch gh#sissaschool/xmlschema#210 mcepl@suse.com # rename tests_factory to factory_tests so it is not discovered by pytest. -Patch0: factory_tests.patch +Patch1: factory_tests.patch # PATCH-FIX-UPSTREAM remove_shebang.patch gh#sissaschool/xmlschema#210 mcepl@suse.com # Remove superfluous shebang -Patch1: remove_shebang.patch +Patch2: remove_shebang.patch # PATCH-FIX-UPSTREAM location_testing_script.patch gh#sissaschool/xmlschema#210 mcepl@suse.com # this patch makes things totally awesome -Patch2: location_testing_script.patch +Patch3: location_testing_script.patch BuildRequires: %{python_module elementpath >= 1.4.0} BuildRequires: %{python_module lxml} BuildRequires: %{python_module pip} @@ -76,13 +79,7 @@ done %check export LANG="en_US.UTF8" -# test_element_tree_import_script is (easily workaroundable) gh#sissaschool/xmlschema#167 -# tests_factory setup is broken -# SKIP_TESTS="test_element_tree_import_script" -# gh#sissaschool/xmlschema#210 -SKIP_TESTS="test_imported_element_tree or test_xml_resource_defuse" -SKIP_TESTS="$SKIP_TESTS or test_xml_resource_from_string" -%pytest -s -k "not ($SKIP_TESTS)" tests +%pytest tests/ %post %python_install_alternative xmlschema-json2xml From e6a956470565b02255d5d58dbb3123683bb01cdfc5f158f03d9a7069a6035828 Mon Sep 17 00:00:00 2001 From: Matej Cepl Date: Tue, 10 Nov 2020 07:46:31 +0000 Subject: [PATCH 4/5] Update imported patch OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-xmlschema?expand=0&rev=23 --- etree_import_in_tests.patch | 194 +++++++++++++++++++++--------------- 1 file changed, 114 insertions(+), 80 deletions(-) diff --git a/etree_import_in_tests.patch b/etree_import_in_tests.patch index e7ffd34..c8af34c 100644 --- a/etree_import_in_tests.patch +++ b/etree_import_in_tests.patch @@ -1,26 +1,22 @@ -diff --git a/tests/test_documents.py b/tests/test_documents.py -index 6c616fe..bd5d8c5 100644 --- a/tests/test_documents.py +++ b/tests/test_documents.py @@ -16,7 +16,6 @@ import io - import pathlib - import tempfile - from decimal import Decimal --from xml.etree import ElementTree - - try: - import lxml.etree as lxml_etree -@@ -27,7 +26,7 @@ from xmlschema import XMLSchema10, XMLSchema11, XmlDocument, \ - XMLResourceError, XMLSchemaValidationError, XMLSchemaDecodeError, \ - to_json, from_json - --from xmlschema.etree import is_etree_element, is_etree_document -+from xmlschema.etree import ElementTree, is_etree_element, is_etree_document - from xmlschema.namespaces import XSD_NAMESPACE, XSI_NAMESPACE - from xmlschema.resources import XMLResource - from xmlschema.documents import get_context -diff --git a/tests/test_etree.py b/tests/test_etree.py -index d16c793..96aba4b 100644 + import pathlib + import tempfile + from decimal import Decimal +-from xml.etree import ElementTree + + try: + import lxml.etree as lxml_etree +@@ -27,7 +26,7 @@ from xmlschema import XMLSchema10, XMLSc + XMLResourceError, XMLSchemaValidationError, XMLSchemaDecodeError, \ + to_json, from_json + +-from xmlschema.etree import is_etree_element, is_etree_document ++from xmlschema.etree import ElementTree, is_etree_element, is_etree_document + from xmlschema.namespaces import XSD_NAMESPACE, XSI_NAMESPACE + from xmlschema.resources import XMLResource + from xmlschema.documents import get_context --- a/tests/test_etree.py +++ b/tests/test_etree.py @@ -11,10 +11,11 @@ @@ -289,7 +285,7 @@ index d16c793..96aba4b 100644 (root, '/'), (root[0], '/b1'), (root[0][0], '/b1/c1'), (root[0][1], '/b1/c2'), (root[1], '/b2'), (root[2], '/b3'), (root[2][0], '/b3/c3') -@@ -203,104 +201,104 @@ class TestElementTree(unittest.TestCase): +@@ -203,104 +201,104 @@ class TestElementTree(unittest.TestCase) def test_etree_getpath(self): root = ElementTree.XML('') @@ -298,15 +294,16 @@ index d16c793..96aba4b 100644 - self.assertEqual(etree.etree_getpath(root[2][0], root), './b3/c3') - self.assertEqual(etree.etree_getpath(root[0], root, parent_path=True), '.') - self.assertEqual(etree.etree_getpath(root[2][0], root, parent_path=True), './b3') +- +- self.assertIsNone(etree.etree_getpath(root, root[0])) +- self.assertIsNone(etree.etree_getpath(root[0], root[1])) +- self.assertIsNone(etree.etree_getpath(root, root, parent_path=True)) + self.assertEqual(etree_getpath(root, root), '.') + self.assertEqual(etree_getpath(root[0], root), './b1') + self.assertEqual(etree_getpath(root[2][0], root), './b3/c3') + self.assertEqual(etree_getpath(root[0], root, parent_path=True), '.') + self.assertEqual(etree_getpath(root[2][0], root, parent_path=True), './b3') - -- self.assertIsNone(etree.etree_getpath(root, root[0])) -- self.assertIsNone(etree.etree_getpath(root[0], root[1])) -- self.assertIsNone(etree.etree_getpath(root, root, parent_path=True)) ++ + self.assertIsNone(etree_getpath(root, root[0])) + self.assertIsNone(etree_getpath(root[0], root[1])) + self.assertIsNone(etree_getpath(root, root, parent_path=True)) @@ -427,7 +424,7 @@ index d16c793..96aba4b 100644 self.assertIn("tails differ: None != 'tail'", str(ctx.exception)) def test_iter_location_hints(self): -@@ -309,7 +307,7 @@ class TestElementTree(unittest.TestCase): +@@ -309,7 +307,7 @@ class TestElementTree(unittest.TestCase) xsi:schemaLocation="http://example.com/xmlschema/ns-A import-case4a.xsd"/>""" ) self.assertListEqual( @@ -436,7 +433,7 @@ index d16c793..96aba4b 100644 [('http://example.com/xmlschema/ns-A', 'import-case4a.xsd')] ) elem = ElementTree.XML( -@@ -317,16 +315,16 @@ class TestElementTree(unittest.TestCase): +@@ -317,16 +315,16 @@ class TestElementTree(unittest.TestCase) xsi:noNamespaceSchemaLocation="schema.xsd"/>""" ) self.assertListEqual( @@ -456,8 +453,6 @@ index d16c793..96aba4b 100644 self.assertListEqual([e.tag for e in root.iter()], ['a', 'b1', 'b2', 'b3']) -diff --git a/tests/test_helpers.py b/tests/test_helpers.py -index a7148ca..29b93ff 100644 --- a/tests/test_helpers.py +++ b/tests/test_helpers.py @@ -12,11 +12,10 @@ @@ -473,32 +468,49 @@ index a7148ca..29b93ff 100644 from xmlschema.qnames import XSD_SCHEMA, XSD_ELEMENT, XSD_SIMPLE_TYPE, XSD_ANNOTATION from xmlschema.helpers import get_xsd_annotation, get_xsd_derivation_attribute, \ get_xsd_form_attribute, raw_xml_encode, count_digits, strictly_equal, \ -diff --git a/tests/test_resources.py b/tests/test_resources.py -index 8fd2073..546bbdb 100644 --- a/tests/test_resources.py +++ b/tests/test_resources.py -@@ -19,7 +19,6 @@ from urllib.error import URLError - from urllib.request import urlopen - from urllib.parse import urlsplit, uses_relative - from pathlib import Path, PureWindowsPath, PurePath --from xml.etree import ElementTree - - try: - import lxml.etree as lxml_etree -@@ -28,7 +27,7 @@ except ImportError: - - from xmlschema import fetch_namespaces, fetch_resource, normalize_url, \ - fetch_schema, fetch_schema_locations, XMLResource, XMLResourceError, XMLSchema --from xmlschema.etree import etree_element, py_etree_element, is_etree_element -+from xmlschema.etree import ElementTree, etree_element, py_etree_element, is_etree_element - from xmlschema.namespaces import XSD_NAMESPACE - from xmlschema.resources import is_url, is_local_url, is_remote_url, \ - url_path_is_file, normalize_locations, LazySelector -diff --git a/tests/test_w3c_suite.py b/tests/test_w3c_suite.py -index 6df61d2..964ce08 100644 +@@ -19,19 +19,22 @@ from urllib.error import URLError + from urllib.request import urlopen + from urllib.parse import urlsplit, uses_relative + from pathlib import Path, PureWindowsPath, PurePath +-from xml.etree import ElementTree + + try: + import lxml.etree as lxml_etree + except ImportError: + lxml_etree = None + +-from xmlschema import fetch_namespaces, fetch_resource, normalize_url, \ +- fetch_schema, fetch_schema_locations, XMLResource, XMLResourceError, XMLSchema +-from xmlschema.etree import etree_element, py_etree_element, is_etree_element ++from xmlschema import XMLResource, XMLSchema ++from xmlschema.etree import (ElementTree, etree_element, ++ py_etree_element, is_etree_element) + from xmlschema.namespaces import XSD_NAMESPACE +-from xmlschema.resources import is_url, is_local_url, is_remote_url, \ +- url_path_is_file, normalize_locations, LazySelector ++from xmlschema.exceptions import XMLResourceError ++from xmlschema.resources import (fetch_namespaces, fetch_resource, ++ fetch_schema, fetch_schema_locations, ++ is_url, is_local_url, is_remote_url, ++ url_path_is_file, normalize_locations, ++ normalize_url, LazySelector) + from xmlschema.testing import SKIP_REMOTE_TESTS + + +@@ -1076,7 +1079,7 @@ class TestResources(unittest.TestCase): + self.assertTrue(isinstance(vh_schema, XMLSchema)) + + xsd_source = """ +- + + """.format(self.vh_xsd_file) --- a/tests/test_w3c_suite.py +++ b/tests/test_w3c_suite.py -@@ -14,7 +14,6 @@ This script runs tests concerning the W3C XML Schema 1.1 test suite. +@@ -14,7 +14,6 @@ This script runs tests concerning the W3 import unittest import argparse import os.path @@ -514,27 +526,59 @@ index 6df61d2..964ce08 100644 TEST_SUITE_NAMESPACE = "http://www.w3.org/XML/2004/xml-schema-test-suite/" XLINK_NAMESPACE = "http://www.w3.org/1999/xlink" -diff --git a/tests/test_wsdl.py b/tests/test_wsdl.py -index c480156..65a5209 100644 --- a/tests/test_wsdl.py +++ b/tests/test_wsdl.py @@ -14,13 +14,11 @@ import unittest - import os - - from xmlschema import XMLSchemaValidationError, XMLSchema10, XMLSchema11 --from xmlschema.etree import ParseError -+from xmlschema.etree import ElementTree, ParseError - from xmlschema.wsdl import WsdlParseError, WsdlComponent, WsdlMessage, \ - WsdlPortType, WsdlOperation, WsdlBinding, WsdlService, Wsdl11Document, \ - WsdlInput, SoapHeader - --from xml.etree import ElementTree -- - - TEST_CASES_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'test_cases/') - -diff --git a/tests/test_xpath.py b/tests/test_xpath.py -index e72b221..eb5acad 100644 + import os + + from xmlschema import XMLSchemaValidationError, XMLSchema10, XMLSchema11 +-from xmlschema.etree import ParseError ++from xmlschema.etree import ElementTree, ParseError + from xmlschema.wsdl import WsdlParseError, WsdlComponent, WsdlMessage, \ + WsdlPortType, WsdlOperation, WsdlBinding, WsdlService, Wsdl11Document, \ + WsdlInput, SoapHeader + +-from xml.etree import ElementTree +- + + TEST_CASES_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'test_cases/') + +@@ -97,7 +95,7 @@ WSDL_DOCUMENT_EXAMPLE = """ + + + +@@ -403,7 +401,7 @@ class TestWsdlDocuments(unittest.TestCas + + def test_wsdl_document_invalid_imports(self): + wsdl_template = """ +- + + """ +@@ -427,7 +425,7 @@ class TestWsdlDocuments(unittest.TestCas + self.assertIn('no element found', str(ctx.exception)) + + wsdl_template = """ +- + +@@ -439,7 +437,7 @@ class TestWsdlDocuments(unittest.TestCas + self.assertIn('namespace to import must be different', str(ctx.exception)) + + wsdl_template = """ +- + --- a/tests/test_xpath.py +++ b/tests/test_xpath.py @@ -12,12 +12,12 @@ @@ -551,8 +595,6 @@ index e72b221..eb5acad 100644 from xmlschema.xpath import XMLSchemaProxy, iter_schema_nodes from xmlschema.validators import XsdAtomic, XsdAtomicRestriction -diff --git a/tests/validation/test_decoding.py b/tests/validation/test_decoding.py -index 908e6bd..ae7742a 100644 --- a/tests/validation/test_decoding.py +++ b/tests/validation/test_decoding.py @@ -12,7 +12,6 @@ import unittest @@ -571,8 +613,6 @@ index 908e6bd..ae7742a 100644 from xmlschema.converters import UnorderedConverter from xmlschema.validators import XMLSchema11 from xmlschema.testing import XsdValidatorTestCase -diff --git a/tests/validation/test_validation.py b/tests/validation/test_validation.py -index be8ce36..b104973 100644 --- a/tests/validation/test_validation.py +++ b/tests/validation/test_validation.py @@ -11,7 +11,6 @@ @@ -591,8 +631,6 @@ index be8ce36..b104973 100644 from xmlschema.validators import XMLSchema11 from xmlschema.testing import XsdValidatorTestCase -diff --git a/tests/validators/test_exceptions.py b/tests/validators/test_exceptions.py -index c23f1d6..86c5635 100644 --- a/tests/validators/test_exceptions.py +++ b/tests/validators/test_exceptions.py @@ -11,10 +11,10 @@ @@ -607,8 +645,6 @@ index c23f1d6..86c5635 100644 from xmlschema.validators.exceptions import XMLSchemaValidatorError, \ XMLSchemaNotBuiltError, XMLSchemaModelDepthError, XMLSchemaValidationError, \ XMLSchemaChildrenValidationError -diff --git a/tests/validators/test_notations.py b/tests/validators/test_notations.py -index 0b48c01..a14baa8 100644 --- a/tests/validators/test_notations.py +++ b/tests/validators/test_notations.py @@ -9,9 +9,9 @@ @@ -622,8 +658,6 @@ index 0b48c01..a14baa8 100644 from xmlschema.qnames import XSD_NOTATION from xmlschema.validators import XMLSchema10, XMLSchema11, XsdNotation -diff --git a/tests/validators/test_xsdbase.py b/tests/validators/test_xsdbase.py -index f5791b4..6182a83 100644 --- a/tests/validators/test_xsdbase.py +++ b/tests/validators/test_xsdbase.py @@ -12,10 +12,10 @@ import unittest @@ -638,7 +672,7 @@ index f5791b4..6182a83 100644 from xmlschema.qnames import XSD_ELEMENT, XSD_ANNOTATION, XSD_ANY_TYPE from xmlschema.namespaces import XSD_NAMESPACE -@@ -766,7 +766,6 @@ class TestParticleMixin(unittest.TestCase): +@@ -766,7 +766,6 @@ class TestParticleMixin(unittest.TestCas if __name__ == '__main__': From 500dc54ae4db1a8a23d26c0cb8940de16e4c636efe08c9f2a6bf140a23961292 Mon Sep 17 00:00:00 2001 From: Matej Cepl Date: Tue, 10 Nov 2020 13:51:01 +0000 Subject: [PATCH 5/5] - Update to 1.3.1. - mainly accepting patches etree_import_in_tests.patch, factory_tests.patch, location_testing_script.patch, which are thus removed. OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-xmlschema?expand=0&rev=24 --- etree_import_in_tests.patch | 682 ---------------------------------- factory_tests.patch | 117 ------ location_testing_script.patch | 23 -- python-xmlschema.changes | 8 + python-xmlschema.spec | 13 +- xmlschema-1.3.0.tar.gz | 3 - xmlschema-1.3.1.tar.gz | 3 + 7 files changed, 13 insertions(+), 836 deletions(-) delete mode 100644 etree_import_in_tests.patch delete mode 100644 factory_tests.patch delete mode 100644 location_testing_script.patch delete mode 100644 xmlschema-1.3.0.tar.gz create mode 100644 xmlschema-1.3.1.tar.gz diff --git a/etree_import_in_tests.patch b/etree_import_in_tests.patch deleted file mode 100644 index c8af34c..0000000 --- a/etree_import_in_tests.patch +++ /dev/null @@ -1,682 +0,0 @@ ---- a/tests/test_documents.py -+++ b/tests/test_documents.py -@@ -16,7 +16,6 @@ import io - import pathlib - import tempfile - from decimal import Decimal --from xml.etree import ElementTree - - try: - import lxml.etree as lxml_etree -@@ -27,7 +26,7 @@ from xmlschema import XMLSchema10, XMLSc - XMLResourceError, XMLSchemaValidationError, XMLSchemaDecodeError, \ - to_json, from_json - --from xmlschema.etree import is_etree_element, is_etree_document -+from xmlschema.etree import ElementTree, is_etree_element, is_etree_document - from xmlschema.namespaces import XSD_NAMESPACE, XSI_NAMESPACE - from xmlschema.resources import XMLResource - from xmlschema.documents import get_context ---- a/tests/test_etree.py -+++ b/tests/test_etree.py -@@ -11,10 +11,11 @@ - import unittest - import os - import platform --from xml.etree import ElementTree - import lxml.etree - --from xmlschema import etree -+from xmlschema.etree import ElementTree, PyElementTree, ParseError, \ -+ SafeXMLParser, etree_tostring, etree_getpath, etree_iter_location_hints, \ -+ etree_iterpath, etree_elements_assert_equal, prune_etree - - TEST_CASES_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'test_cases/') - -@@ -25,176 +26,173 @@ def casepath(relative_path): - - class TestElementTree(unittest.TestCase): - -- def test_imported_element_tree(self): -- self.assertIs(ElementTree, etree.ElementTree) -- - def test_element_string_serialization(self): -- self.assertRaises(TypeError, etree.etree_tostring, '') -+ self.assertRaises(TypeError, etree_tostring, '') - - elem = ElementTree.Element('element') -- self.assertEqual(etree.etree_tostring(elem), '') -- self.assertEqual(etree.etree_tostring(elem, xml_declaration=True), '') -+ self.assertEqual(etree_tostring(elem), '') -+ self.assertEqual(etree_tostring(elem, xml_declaration=True), '') - -- self.assertEqual(etree.etree_tostring(elem, encoding='us-ascii'), b'') -- self.assertEqual(etree.etree_tostring(elem, encoding='us-ascii', indent=' '), -+ self.assertEqual(etree_tostring(elem, encoding='us-ascii'), b'') -+ self.assertEqual(etree_tostring(elem, encoding='us-ascii', indent=' '), - b' ') -- self.assertEqual(etree.etree_tostring(elem, encoding='us-ascii', xml_declaration=True), -+ self.assertEqual(etree_tostring(elem, encoding='us-ascii', xml_declaration=True), - b'\n') - -- self.assertEqual(etree.etree_tostring(elem, encoding='ascii'), -+ self.assertEqual(etree_tostring(elem, encoding='ascii'), - b"\n") -- self.assertEqual(etree.etree_tostring(elem, encoding='ascii', xml_declaration=False), -+ self.assertEqual(etree_tostring(elem, encoding='ascii', xml_declaration=False), - b'') -- self.assertEqual(etree.etree_tostring(elem, encoding='utf-8'), b'') -- self.assertEqual(etree.etree_tostring(elem, encoding='utf-8', xml_declaration=True), -+ self.assertEqual(etree_tostring(elem, encoding='utf-8'), b'') -+ self.assertEqual(etree_tostring(elem, encoding='utf-8', xml_declaration=True), - b'\n') - -- self.assertEqual(etree.etree_tostring(elem, encoding='iso-8859-1'), -+ self.assertEqual(etree_tostring(elem, encoding='iso-8859-1'), - b"\n") -- self.assertEqual(etree.etree_tostring(elem, encoding='iso-8859-1', xml_declaration=False), -+ self.assertEqual(etree_tostring(elem, encoding='iso-8859-1', xml_declaration=False), - b"") - -- self.assertEqual(etree.etree_tostring(elem, method='html'), '') -- self.assertEqual(etree.etree_tostring(elem, method='text'), '') -+ self.assertEqual(etree_tostring(elem, method='html'), '') -+ self.assertEqual(etree_tostring(elem, method='text'), '') - -- root = etree.ElementTree.XML('\n' -- ' text1\n' -- ' text2\n' -- '') -- self.assertEqual(etree.etree_tostring(root, method='text'), '\n text1\n text2') -+ root = ElementTree.XML('\n' -+ ' text1\n' -+ ' text2\n' -+ '') -+ self.assertEqual(etree_tostring(root, method='text'), '\n text1\n text2') - - def test_py_element_string_serialization(self): -- elem = etree.PyElementTree.Element('element') -- self.assertEqual(etree.etree_tostring(elem), '') -- self.assertEqual(etree.etree_tostring(elem, xml_declaration=True), '') -+ elem = PyElementTree.Element('element') -+ self.assertEqual(etree_tostring(elem), '') -+ self.assertEqual(etree_tostring(elem, xml_declaration=True), '') - -- self.assertEqual(etree.etree_tostring(elem, encoding='us-ascii'), b'') -- self.assertEqual(etree.etree_tostring(elem, encoding='us-ascii', xml_declaration=True), -+ self.assertEqual(etree_tostring(elem, encoding='us-ascii'), b'') -+ self.assertEqual(etree_tostring(elem, encoding='us-ascii', xml_declaration=True), - b'\n') - -- self.assertEqual(etree.etree_tostring(elem, encoding='ascii'), -+ self.assertEqual(etree_tostring(elem, encoding='ascii'), - b"\n") -- self.assertEqual(etree.etree_tostring(elem, encoding='ascii', xml_declaration=False), -+ self.assertEqual(etree_tostring(elem, encoding='ascii', xml_declaration=False), - b'') -- self.assertEqual(etree.etree_tostring(elem, encoding='utf-8'), b'') -- self.assertEqual(etree.etree_tostring(elem, encoding='utf-8', xml_declaration=True), -+ self.assertEqual(etree_tostring(elem, encoding='utf-8'), b'') -+ self.assertEqual(etree_tostring(elem, encoding='utf-8', xml_declaration=True), - b'\n') - -- self.assertEqual(etree.etree_tostring(elem, encoding='iso-8859-1'), -+ self.assertEqual(etree_tostring(elem, encoding='iso-8859-1'), - b"\n") -- self.assertEqual(etree.etree_tostring(elem, encoding='iso-8859-1', xml_declaration=False), -+ self.assertEqual(etree_tostring(elem, encoding='iso-8859-1', xml_declaration=False), - b"") - -- self.assertEqual(etree.etree_tostring(elem, method='html'), '') -- self.assertEqual(etree.etree_tostring(elem, method='text'), '') -+ self.assertEqual(etree_tostring(elem, method='html'), '') -+ self.assertEqual(etree_tostring(elem, method='text'), '') - -- root = etree.PyElementTree.XML('\n' -- ' text1\n' -- ' text2\n' -- '') -- self.assertEqual(etree.etree_tostring(root, method='text'), '\n text1\n text2') -+ root = PyElementTree.XML('\n' -+ ' text1\n' -+ ' text2\n' -+ '') -+ self.assertEqual(etree_tostring(root, method='text'), '\n text1\n text2') - - def test_lxml_element_string_serialization(self): - elem = lxml.etree.Element('element') -- self.assertEqual(etree.etree_tostring(elem), '') -- self.assertEqual(etree.etree_tostring(elem, xml_declaration=True), '') -+ self.assertEqual(etree_tostring(elem), '') -+ self.assertEqual(etree_tostring(elem, xml_declaration=True), '') - -- self.assertEqual(etree.etree_tostring(elem, encoding='us-ascii'), b'') -- self.assertEqual(etree.etree_tostring(elem, encoding='us-ascii', xml_declaration=True), -+ self.assertEqual(etree_tostring(elem, encoding='us-ascii'), b'') -+ self.assertEqual(etree_tostring(elem, encoding='us-ascii', xml_declaration=True), - b'\n') - -- self.assertEqual(etree.etree_tostring(elem, encoding='ascii'), b'') -- self.assertEqual(etree.etree_tostring(elem, encoding='ascii', xml_declaration=True), -+ self.assertEqual(etree_tostring(elem, encoding='ascii'), b'') -+ self.assertEqual(etree_tostring(elem, encoding='ascii', xml_declaration=True), - b'\n') - -- self.assertEqual(etree.etree_tostring(elem, encoding='utf-8'), b'') -- self.assertEqual(etree.etree_tostring(elem, encoding='utf-8', xml_declaration=True), -+ self.assertEqual(etree_tostring(elem, encoding='utf-8'), b'') -+ self.assertEqual(etree_tostring(elem, encoding='utf-8', xml_declaration=True), - b'\n') - -- self.assertEqual(etree.etree_tostring(elem, encoding='iso-8859-1'), -+ self.assertEqual(etree_tostring(elem, encoding='iso-8859-1'), - b"\n") -- self.assertEqual(etree.etree_tostring(elem, encoding='iso-8859-1', xml_declaration=False), -+ self.assertEqual(etree_tostring(elem, encoding='iso-8859-1', xml_declaration=False), - b"") - -- self.assertEqual(etree.etree_tostring(elem, method='html'), '') -- self.assertEqual(etree.etree_tostring(elem, method='text'), '') -+ self.assertEqual(etree_tostring(elem, method='html'), '') -+ self.assertEqual(etree_tostring(elem, method='text'), '') - - root = lxml.etree.XML('\n' - ' text1\n' - ' text2\n' - '') -- self.assertEqual(etree.etree_tostring(root, method='text'), '\n text1\n text2') -+ self.assertEqual(etree_tostring(root, method='text'), '\n text1\n text2') - - def test_defuse_xml_entities(self): - xml_file = casepath('resources/with_entity.xml') - -- elem = etree.ElementTree.parse(xml_file).getroot() -+ elem = ElementTree.parse(xml_file).getroot() - self.assertEqual(elem.text, 'abc') - -- parser = etree.SafeXMLParser(target=etree.PyElementTree.TreeBuilder()) -- with self.assertRaises(etree.PyElementTree.ParseError) as ctx: -- etree.ElementTree.parse(xml_file, parser=parser) -+ parser = SafeXMLParser(target=PyElementTree.TreeBuilder()) -+ with self.assertRaises(PyElementTree.ParseError) as ctx: -+ ElementTree.parse(xml_file, parser=parser) - self.assertEqual("Entities are forbidden (entity_name='e')", str(ctx.exception)) - - def test_defuse_xml_external_entities(self): - xml_file = casepath('resources/external_entity.xml') - -- with self.assertRaises(etree.ParseError) as ctx: -- etree.ElementTree.parse(xml_file) -+ with self.assertRaises(ParseError) as ctx: -+ ElementTree.parse(xml_file) - self.assertIn("undefined entity &ee", str(ctx.exception)) - -- parser = etree.SafeXMLParser(target=etree.PyElementTree.TreeBuilder()) -- with self.assertRaises(etree.PyElementTree.ParseError) as ctx: -- etree.ElementTree.parse(xml_file, parser=parser) -+ parser = SafeXMLParser(target=PyElementTree.TreeBuilder()) -+ with self.assertRaises(PyElementTree.ParseError) as ctx: -+ ElementTree.parse(xml_file, parser=parser) - self.assertEqual("Entities are forbidden (entity_name='ee')", str(ctx.exception)) - - def test_defuse_xml_unused_external_entities(self): - xml_file = casepath('resources/unused_external_entity.xml') - -- elem = etree.ElementTree.parse(xml_file).getroot() -+ elem = ElementTree.parse(xml_file).getroot() - self.assertEqual(elem.text, 'abc') - -- parser = etree.SafeXMLParser(target=etree.PyElementTree.TreeBuilder()) -- with self.assertRaises(etree.PyElementTree.ParseError) as ctx: -- etree.ElementTree.parse(xml_file, parser=parser) -+ parser = SafeXMLParser(target=PyElementTree.TreeBuilder()) -+ with self.assertRaises(PyElementTree.ParseError) as ctx: -+ ElementTree.parse(xml_file, parser=parser) - self.assertEqual("Entities are forbidden (entity_name='ee')", str(ctx.exception)) - - def test_defuse_xml_unparsed_entities(self): - xml_file = casepath('resources/unparsed_entity.xml') - -- parser = etree.SafeXMLParser(target=etree.PyElementTree.TreeBuilder()) -- with self.assertRaises(etree.PyElementTree.ParseError) as ctx: -- etree.ElementTree.parse(xml_file, parser=parser) -+ parser = SafeXMLParser(target=PyElementTree.TreeBuilder()) -+ with self.assertRaises(PyElementTree.ParseError) as ctx: -+ ElementTree.parse(xml_file, parser=parser) - self.assertEqual("Unparsed entities are forbidden (entity_name='logo_file')", - str(ctx.exception)) - - def test_defuse_xml_unused_unparsed_entities(self): - xml_file = casepath('resources/unused_unparsed_entity.xml') - -- elem = etree.ElementTree.parse(xml_file).getroot() -+ elem = ElementTree.parse(xml_file).getroot() - self.assertIsNone(elem.text) - -- parser = etree.SafeXMLParser(target=etree.PyElementTree.TreeBuilder()) -- with self.assertRaises(etree.PyElementTree.ParseError) as ctx: -- etree.ElementTree.parse(xml_file, parser=parser) -+ parser = SafeXMLParser(target=PyElementTree.TreeBuilder()) -+ with self.assertRaises(PyElementTree.ParseError) as ctx: -+ ElementTree.parse(xml_file, parser=parser) - self.assertEqual("Unparsed entities are forbidden (entity_name='logo_file')", - str(ctx.exception)) - - def test_etree_iterpath(self): - root = ElementTree.XML('') - -- items = list(etree.etree_iterpath(root)) -+ items = list(etree_iterpath(root)) - self.assertListEqual(items, [ - (root, '.'), (root[0], './b1'), (root[0][0], './b1/c1'), - (root[0][1], './b1/c2'), (root[1], './b2'), (root[2], './b3'), - (root[2][0], './b3/c3') - ]) - -- self.assertListEqual(items, list(etree.etree_iterpath(root, tag='*'))) -- self.assertListEqual(items, list(etree.etree_iterpath(root, path=''))) -- self.assertListEqual(items, list(etree.etree_iterpath(root, path=None))) -+ self.assertListEqual(items, list(etree_iterpath(root, tag='*'))) -+ self.assertListEqual(items, list(etree_iterpath(root, path=''))) -+ self.assertListEqual(items, list(etree_iterpath(root, path=None))) - -- self.assertListEqual(list(etree.etree_iterpath(root, path='/')), [ -+ self.assertListEqual(list(etree_iterpath(root, path='/')), [ - (root, '/'), (root[0], '/b1'), (root[0][0], '/b1/c1'), - (root[0][1], '/b1/c2'), (root[1], '/b2'), (root[2], '/b3'), - (root[2][0], '/b3/c3') -@@ -203,104 +201,104 @@ class TestElementTree(unittest.TestCase) - def test_etree_getpath(self): - root = ElementTree.XML('') - -- self.assertEqual(etree.etree_getpath(root, root), '.') -- self.assertEqual(etree.etree_getpath(root[0], root), './b1') -- self.assertEqual(etree.etree_getpath(root[2][0], root), './b3/c3') -- self.assertEqual(etree.etree_getpath(root[0], root, parent_path=True), '.') -- self.assertEqual(etree.etree_getpath(root[2][0], root, parent_path=True), './b3') -- -- self.assertIsNone(etree.etree_getpath(root, root[0])) -- self.assertIsNone(etree.etree_getpath(root[0], root[1])) -- self.assertIsNone(etree.etree_getpath(root, root, parent_path=True)) -+ self.assertEqual(etree_getpath(root, root), '.') -+ self.assertEqual(etree_getpath(root[0], root), './b1') -+ self.assertEqual(etree_getpath(root[2][0], root), './b3/c3') -+ self.assertEqual(etree_getpath(root[0], root, parent_path=True), '.') -+ self.assertEqual(etree_getpath(root[2][0], root, parent_path=True), './b3') -+ -+ self.assertIsNone(etree_getpath(root, root[0])) -+ self.assertIsNone(etree_getpath(root[0], root[1])) -+ self.assertIsNone(etree_getpath(root, root, parent_path=True)) - - def test_etree_elements_assert_equal(self): - e1 = ElementTree.XML('text\n\n') - e2 = ElementTree.XML('text\n\n') - -- self.assertIsNone(etree.etree_elements_assert_equal(e1, e1)) -- self.assertIsNone(etree.etree_elements_assert_equal(e1, e2)) -+ self.assertIsNone(etree_elements_assert_equal(e1, e1)) -+ self.assertIsNone(etree_elements_assert_equal(e1, e2)) - - e2 = lxml.etree.XML('text\n\n') -- self.assertIsNone(etree.etree_elements_assert_equal(e1, e2)) -+ self.assertIsNone(etree_elements_assert_equal(e1, e2)) - - e2 = ElementTree.XML('text\n\n') - with self.assertRaises(AssertionError) as ctx: -- etree.etree_elements_assert_equal(e1, e2) -+ etree_elements_assert_equal(e1, e2) - self.assertIn("has lesser children than text \n\n') -- self.assertIsNone(etree.etree_elements_assert_equal(e1, e2, strict=False)) -+ self.assertIsNone(etree_elements_assert_equal(e1, e2, strict=False)) - with self.assertRaises(AssertionError) as ctx: -- etree.etree_elements_assert_equal(e1, e2) -+ etree_elements_assert_equal(e1, e2) - self.assertIn("texts differ: 'text' != 'text '", str(ctx.exception)) - - e2 = ElementTree.XML('text\ntext\n') - with self.assertRaises(AssertionError) as ctx: -- etree.etree_elements_assert_equal(e1, e2, strict=False) -+ etree_elements_assert_equal(e1, e2, strict=False) - self.assertIn("texts differ: None != 'text'", str(ctx.exception)) - - e2 = ElementTree.XML('text\n') -- self.assertIsNone(etree.etree_elements_assert_equal(e1, e2)) -+ self.assertIsNone(etree_elements_assert_equal(e1, e2)) - - e2 = ElementTree.XML('text\n') -- self.assertIsNone(etree.etree_elements_assert_equal(e1, e2, strict=False)) -+ self.assertIsNone(etree_elements_assert_equal(e1, e2, strict=False)) - with self.assertRaises(AssertionError) as ctx: -- etree.etree_elements_assert_equal(e1, e2) -+ etree_elements_assert_equal(e1, e2) - self.assertIn(r"tails differ: '\n' != None", str(ctx.exception)) - - e2 = ElementTree.XML('text\n\n') -- self.assertIsNone(etree.etree_elements_assert_equal(e1, e2, strict=False)) -+ self.assertIsNone(etree_elements_assert_equal(e1, e2, strict=False)) - with self.assertRaises(AssertionError) as ctx: -- etree.etree_elements_assert_equal(e1, e2) -+ etree_elements_assert_equal(e1, e2) - self.assertIn("attributes differ: {'a': '1'} != {'a': '1 '}", str(ctx.exception)) - - e2 = ElementTree.XML('text\n\n') - with self.assertRaises(AssertionError) as ctx: -- etree.etree_elements_assert_equal(e1, e2, strict=False) -+ etree_elements_assert_equal(e1, e2, strict=False) - self.assertIn("attribute 'a' values differ: '1' != '2'", str(ctx.exception)) - - e2 = ElementTree.XML('text\n\n') -- self.assertIsNone(etree.etree_elements_assert_equal(e1, e2)) -- self.assertIsNone(etree.etree_elements_assert_equal(e1, e2, skip_comments=False)) -+ self.assertIsNone(etree_elements_assert_equal(e1, e2)) -+ self.assertIsNone(etree_elements_assert_equal(e1, e2, skip_comments=False)) - - e2 = lxml.etree.XML('text\n\n') -- self.assertIsNone(etree.etree_elements_assert_equal(e1, e2)) -+ self.assertIsNone(etree_elements_assert_equal(e1, e2)) - - e1 = ElementTree.XML('+1') - e2 = ElementTree.XML('+ 1 ') -- self.assertIsNone(etree.etree_elements_assert_equal(e1, e2, strict=False)) -+ self.assertIsNone(etree_elements_assert_equal(e1, e2, strict=False)) - - e1 = ElementTree.XML('+1') - e2 = ElementTree.XML('+1.1 ') - - with self.assertRaises(AssertionError) as ctx: -- etree.etree_elements_assert_equal(e1, e2, strict=False) -+ etree_elements_assert_equal(e1, e2, strict=False) - self.assertIn("texts differ: '+1' != '+1.1 '", str(ctx.exception)) - - e1 = ElementTree.XML('1') - e2 = ElementTree.XML('true ') -- self.assertIsNone(etree.etree_elements_assert_equal(e1, e2, strict=False)) -- self.assertIsNone(etree.etree_elements_assert_equal(e2, e1, strict=False)) -+ self.assertIsNone(etree_elements_assert_equal(e1, e2, strict=False)) -+ self.assertIsNone(etree_elements_assert_equal(e2, e1, strict=False)) - - e2 = ElementTree.XML('false ') - with self.assertRaises(AssertionError) as ctx: -- etree.etree_elements_assert_equal(e1, e2, strict=False) -+ etree_elements_assert_equal(e1, e2, strict=False) - self.assertIn("texts differ: '1' != 'false '", str(ctx.exception)) - - e1 = ElementTree.XML(' 0') -- self.assertIsNone(etree.etree_elements_assert_equal(e1, e2, strict=False)) -- self.assertIsNone(etree.etree_elements_assert_equal(e2, e1, strict=False)) -+ self.assertIsNone(etree_elements_assert_equal(e1, e2, strict=False)) -+ self.assertIsNone(etree_elements_assert_equal(e2, e1, strict=False)) - - e2 = ElementTree.XML('true ') - with self.assertRaises(AssertionError) as ctx: -- etree.etree_elements_assert_equal(e1, e2, strict=False) -+ etree_elements_assert_equal(e1, e2, strict=False) - self.assertIn("texts differ: ' 0' != 'true '", str(ctx.exception)) - - e1 = ElementTree.XML('text\n\n') - e2 = ElementTree.XML('texttail\n\n') - - with self.assertRaises(AssertionError) as ctx: -- etree.etree_elements_assert_equal(e1, e2, strict=False) -+ etree_elements_assert_equal(e1, e2, strict=False) - self.assertIn("tails differ: None != 'tail'", str(ctx.exception)) - - def test_iter_location_hints(self): -@@ -309,7 +307,7 @@ class TestElementTree(unittest.TestCase) - xsi:schemaLocation="http://example.com/xmlschema/ns-A import-case4a.xsd"/>""" - ) - self.assertListEqual( -- list(etree.etree_iter_location_hints(elem)), -+ list(etree_iter_location_hints(elem)), - [('http://example.com/xmlschema/ns-A', 'import-case4a.xsd')] - ) - elem = ElementTree.XML( -@@ -317,16 +315,16 @@ class TestElementTree(unittest.TestCase) - xsi:noNamespaceSchemaLocation="schema.xsd"/>""" - ) - self.assertListEqual( -- list(etree.etree_iter_location_hints(elem)), [('', 'schema.xsd')] -+ list(etree_iter_location_hints(elem)), [('', 'schema.xsd')] - ) - - def test_prune_etree(self): - root = ElementTree.XML('') -- etree.prune_etree(root, selector=lambda x: x.tag == 'b1') -+ prune_etree(root, selector=lambda x: x.tag == 'b1') - self.assertListEqual([e.tag for e in root.iter()], ['a', 'b2', 'b3', 'c3']) - - root = ElementTree.XML('') -- etree.prune_etree(root, selector=lambda x: x.tag.startswith('c')) -+ prune_etree(root, selector=lambda x: x.tag.startswith('c')) - self.assertListEqual([e.tag for e in root.iter()], ['a', 'b1', 'b2', 'b3']) - - ---- a/tests/test_helpers.py -+++ b/tests/test_helpers.py -@@ -12,11 +12,10 @@ - import unittest - import sys - import decimal --import xml.etree.ElementTree as ElementTree - from collections import OrderedDict - - from xmlschema import XMLSchema, XMLSchemaParseError --from xmlschema.etree import etree_element, prune_etree -+from xmlschema.etree import ElementTree, etree_element, prune_etree - from xmlschema.qnames import XSD_SCHEMA, XSD_ELEMENT, XSD_SIMPLE_TYPE, XSD_ANNOTATION - from xmlschema.helpers import get_xsd_annotation, get_xsd_derivation_attribute, \ - get_xsd_form_attribute, raw_xml_encode, count_digits, strictly_equal, \ ---- a/tests/test_resources.py -+++ b/tests/test_resources.py -@@ -19,19 +19,22 @@ from urllib.error import URLError - from urllib.request import urlopen - from urllib.parse import urlsplit, uses_relative - from pathlib import Path, PureWindowsPath, PurePath --from xml.etree import ElementTree - - try: - import lxml.etree as lxml_etree - except ImportError: - lxml_etree = None - --from xmlschema import fetch_namespaces, fetch_resource, normalize_url, \ -- fetch_schema, fetch_schema_locations, XMLResource, XMLResourceError, XMLSchema --from xmlschema.etree import etree_element, py_etree_element, is_etree_element -+from xmlschema import XMLResource, XMLSchema -+from xmlschema.etree import (ElementTree, etree_element, -+ py_etree_element, is_etree_element) - from xmlschema.namespaces import XSD_NAMESPACE --from xmlschema.resources import is_url, is_local_url, is_remote_url, \ -- url_path_is_file, normalize_locations, LazySelector -+from xmlschema.exceptions import XMLResourceError -+from xmlschema.resources import (fetch_namespaces, fetch_resource, -+ fetch_schema, fetch_schema_locations, -+ is_url, is_local_url, is_remote_url, -+ url_path_is_file, normalize_locations, -+ normalize_url, LazySelector) - from xmlschema.testing import SKIP_REMOTE_TESTS - - -@@ -1076,7 +1079,7 @@ class TestResources(unittest.TestCase): - self.assertTrue(isinstance(vh_schema, XMLSchema)) - - xsd_source = """ -- - - """.format(self.vh_xsd_file) ---- a/tests/test_w3c_suite.py -+++ b/tests/test_w3c_suite.py -@@ -14,7 +14,6 @@ This script runs tests concerning the W3 - import unittest - import argparse - import os.path --import xml.etree.ElementTree as ElementTree - import warnings - - try: -@@ -23,6 +22,7 @@ except ImportError: - lxml_etree = None - - from xmlschema import validate, XMLSchema10, XMLSchema11, XMLSchemaException -+from xmlschema.etree import ElementTree - - TEST_SUITE_NAMESPACE = "http://www.w3.org/XML/2004/xml-schema-test-suite/" - XLINK_NAMESPACE = "http://www.w3.org/1999/xlink" ---- a/tests/test_wsdl.py -+++ b/tests/test_wsdl.py -@@ -14,13 +14,11 @@ import unittest - import os - - from xmlschema import XMLSchemaValidationError, XMLSchema10, XMLSchema11 --from xmlschema.etree import ParseError -+from xmlschema.etree import ElementTree, ParseError - from xmlschema.wsdl import WsdlParseError, WsdlComponent, WsdlMessage, \ - WsdlPortType, WsdlOperation, WsdlBinding, WsdlService, Wsdl11Document, \ - WsdlInput, SoapHeader - --from xml.etree import ElementTree -- - - TEST_CASES_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'test_cases/') - -@@ -97,7 +95,7 @@ WSDL_DOCUMENT_EXAMPLE = """ - - - -@@ -403,7 +401,7 @@ class TestWsdlDocuments(unittest.TestCas - - def test_wsdl_document_invalid_imports(self): - wsdl_template = """ -- - - """ -@@ -427,7 +425,7 @@ class TestWsdlDocuments(unittest.TestCas - self.assertIn('no element found', str(ctx.exception)) - - wsdl_template = """ -- - -@@ -439,7 +437,7 @@ class TestWsdlDocuments(unittest.TestCas - self.assertIn('namespace to import must be different', str(ctx.exception)) - - wsdl_template = """ -- - ---- a/tests/test_xpath.py -+++ b/tests/test_xpath.py -@@ -12,12 +12,12 @@ - - import unittest - import os --import xml.etree.ElementTree as ElementTree - from elementpath import XPath1Parser, XPath2Parser, Selector, \ - AttributeNode, TypedElement, ElementPathSyntaxError - - from xmlschema import XMLSchema10, XMLSchema11, XsdElement, XsdAttribute - from xmlschema.namespaces import XSD_NAMESPACE -+from xmlschema.etree import ElementTree - from xmlschema.xpath import XMLSchemaProxy, iter_schema_nodes - from xmlschema.validators import XsdAtomic, XsdAtomicRestriction - ---- a/tests/validation/test_decoding.py -+++ b/tests/validation/test_decoding.py -@@ -12,7 +12,6 @@ import unittest - import os - from decimal import Decimal - import base64 --from xml.etree import ElementTree - - try: - import lxml.etree as lxml_etree -@@ -24,6 +23,7 @@ import xmlschema - from xmlschema import XMLSchemaValidationError, ParkerConverter, BadgerFishConverter, \ - AbderaConverter, JsonMLConverter, ColumnarConverter - -+from xmlschema.etree import ElementTree - from xmlschema.converters import UnorderedConverter - from xmlschema.validators import XMLSchema11 - from xmlschema.testing import XsdValidatorTestCase ---- a/tests/validation/test_validation.py -+++ b/tests/validation/test_validation.py -@@ -11,7 +11,6 @@ - import unittest - import os - import sys --from xml.etree import ElementTree - - try: - import lxml.etree as lxml_etree -@@ -21,6 +20,7 @@ except ImportError: - import xmlschema - from xmlschema import XMLSchemaValidationError - -+from xmlschema.etree import ElementTree - from xmlschema.validators import XMLSchema11 - from xmlschema.testing import XsdValidatorTestCase - ---- a/tests/validators/test_exceptions.py -+++ b/tests/validators/test_exceptions.py -@@ -11,10 +11,10 @@ - import unittest - import os - import io --import xml.etree.ElementTree as ElementTree - import lxml.etree - - from xmlschema import XMLSchema, XMLResource -+from xmlschema.etree import ElementTree - from xmlschema.validators.exceptions import XMLSchemaValidatorError, \ - XMLSchemaNotBuiltError, XMLSchemaModelDepthError, XMLSchemaValidationError, \ - XMLSchemaChildrenValidationError ---- a/tests/validators/test_notations.py -+++ b/tests/validators/test_notations.py -@@ -9,9 +9,9 @@ - # @author Davide Brunato - # - import unittest --import xml.etree.ElementTree as ElementTree - - from xmlschema import XMLSchemaParseError -+from xmlschema.etree import ElementTree - from xmlschema.qnames import XSD_NOTATION - from xmlschema.validators import XMLSchema10, XMLSchema11, XsdNotation - ---- a/tests/validators/test_xsdbase.py -+++ b/tests/validators/test_xsdbase.py -@@ -12,10 +12,10 @@ import unittest - import os - import platform - import re --import xml.etree.ElementTree as ElementTree - - from xmlschema.validators import XsdValidator, XsdComponent, XMLSchema10, \ - XMLSchema11, XMLSchemaParseError, XMLSchemaValidationError, XsdGroup, XsdSimpleType -+from xmlschema.etree import ElementTree - from xmlschema.qnames import XSD_ELEMENT, XSD_ANNOTATION, XSD_ANY_TYPE - from xmlschema.namespaces import XSD_NAMESPACE - -@@ -766,7 +766,6 @@ class TestParticleMixin(unittest.TestCas - - - if __name__ == '__main__': -- import platform - header_template = "Test xmlschema's XSD base classes with Python {} on {}" - header = header_template.format(platform.python_version(), platform.platform()) - print('{0}\n{1}\n{0}'.format("*" * len(header), header)) diff --git a/factory_tests.patch b/factory_tests.patch deleted file mode 100644 index c6f42b7..0000000 --- a/factory_tests.patch +++ /dev/null @@ -1,117 +0,0 @@ ---- a/tests/test_all.py -+++ b/tests/test_all.py -@@ -13,7 +13,7 @@ if __name__ == '__main__': - import os - import platform - -- from xmlschema.testing import tests_factory, make_schema_test_class, \ -+ from xmlschema.testing import factory_tests, make_schema_test_class, \ - make_validation_test_class, get_test_program_args_parser - - DEFAULT_TESTFILES = os.path.join(os.path.dirname(__file__), 'test_cases/testfiles') -@@ -46,7 +46,7 @@ if __name__ == '__main__': - - args = get_test_program_args_parser(DEFAULT_TESTFILES).parse_args() - -- schema_tests = tests_factory( -+ schema_tests = factory_tests( - test_class_builder=make_schema_test_class, - testfiles=args.testfiles, - suffix='xsd', -@@ -54,7 +54,7 @@ if __name__ == '__main__': - ) - globals().update(schema_tests) - -- validation_tests = tests_factory( -+ validation_tests = factory_tests( - test_class_builder=make_validation_test_class, - testfiles=args.testfiles, - suffix='xml', ---- a/tests/test_schemas.py -+++ b/tests/test_schemas.py -@@ -13,7 +13,7 @@ - import os - - from xmlschema.testing import get_test_program_args_parser, \ -- tests_factory, make_schema_test_class -+ factory_tests, make_schema_test_class - - DEFAULT_TESTFILES = os.path.join(os.path.dirname(__file__), 'test_cases/testfiles') - -@@ -24,7 +24,7 @@ if __name__ == '__main__': - - args = get_test_program_args_parser(DEFAULT_TESTFILES).parse_args() - -- schema_tests = tests_factory( -+ schema_tests = factory_tests( - test_class_builder=make_schema_test_class, - testfiles=args.testfiles, - suffix='xsd', -@@ -47,7 +47,7 @@ if __name__ == '__main__': - catchbreak=args.catchbreak, buffer=args.buffer) - else: - # Creates schema tests from XSD files -- globals().update(tests_factory( -+ globals().update(factory_tests( - test_class_builder=make_schema_test_class, - suffix='xsd', - testfiles=DEFAULT_TESTFILES ---- a/tests/test_validation.py -+++ b/tests/test_validation.py -@@ -13,7 +13,7 @@ - import os - - from xmlschema.testing import get_test_program_args_parser, \ -- tests_factory, make_validation_test_class -+ factory_tests, make_validation_test_class - - DEFAULT_TESTFILES = os.path.join(os.path.dirname(__file__), 'test_cases/testfiles') - -@@ -24,7 +24,7 @@ if __name__ == '__main__': - - args = get_test_program_args_parser(DEFAULT_TESTFILES).parse_args() - -- validation_tests = tests_factory( -+ validation_tests = factory_tests( - test_class_builder=make_validation_test_class, - testfiles=args.testfiles, - suffix='xml', -@@ -47,7 +47,7 @@ if __name__ == '__main__': - catchbreak=args.catchbreak, buffer=args.buffer) - else: - # Creates schema tests from XSD files -- globals().update(tests_factory( -+ globals().update(factory_tests( - test_class_builder=make_validation_test_class, - suffix='xml', - testfiles=DEFAULT_TESTFILES ---- a/xmlschema/testing/__init__.py -+++ b/xmlschema/testing/__init__.py -@@ -23,7 +23,7 @@ from urllib.error import URLError - from .case_class import XsdValidatorTestCase - from .builders import make_schema_test_class, make_validation_test_class - from .factory import get_test_args, xsd_version_number, defuse_data, \ -- get_test_program_args_parser, get_test_line_args_parser, tests_factory -+ get_test_program_args_parser, get_test_line_args_parser, factory_tests - from .observers import SchemaObserver, ObservedXMLSchema10, ObservedXMLSchema11 - - -@@ -46,6 +46,6 @@ SKIP_REMOTE_TESTS = not has_network_acce - __all__ = [ - 'XsdValidatorTestCase', 'make_schema_test_class', 'make_validation_test_class', - 'get_test_args', 'xsd_version_number', 'defuse_data', 'get_test_program_args_parser', -- 'get_test_line_args_parser', 'tests_factory', 'SchemaObserver', 'ObservedXMLSchema10', -+ 'get_test_line_args_parser', 'factory_tests', 'SchemaObserver', 'ObservedXMLSchema10', - 'ObservedXMLSchema11', 'has_network_access', 'SKIP_REMOTE_TESTS', - ] ---- a/xmlschema/testing/factory.py -+++ b/xmlschema/testing/factory.py -@@ -117,7 +117,7 @@ def get_test_line_args_parser(): - return parser - - --def tests_factory(test_class_builder, testfiles, suffix, check_with_lxml=False): -+def factory_tests(test_class_builder, testfiles, suffix, check_with_lxml=False): - """ - Factory function for file based schema/validation cases. - diff --git a/location_testing_script.patch b/location_testing_script.patch deleted file mode 100644 index ddc2c38..0000000 --- a/location_testing_script.patch +++ /dev/null @@ -1,23 +0,0 @@ ---- - tests/test_etree_import.py | 3 +-- - 1 file changed, 1 insertion(+), 2 deletions(-) - ---- a/tests/test_etree_import.py -+++ b/tests/test_etree_import.py -@@ -15,7 +15,6 @@ import importlib - import subprocess - import platform - -- - def is_element_tree_imported(): - return '_elementtree' in sys.modules or 'xml.etree.ElementTree' in sys.modules - -@@ -42,7 +41,7 @@ class TestElementTreeImport(unittest.Tes - def test_element_tree_import_script(self): - test_dir = os.path.dirname(__file__) or '.' - -- cmd = [os.path.join(test_dir, 'check_etree_import.py')] -+ cmd = [sys.executable, os.path.join(test_dir, 'check_etree_import.py')] - process = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) - - stderr = process.stderr.decode('utf-8') diff --git a/python-xmlschema.changes b/python-xmlschema.changes index 66ba4b3..3b1d7ef 100644 --- a/python-xmlschema.changes +++ b/python-xmlschema.changes @@ -1,3 +1,11 @@ +------------------------------------------------------------------- +Tue Nov 10 13:49:08 UTC 2020 - Matej Cepl + +- Update to 1.3.1. + - mainly accepting patches etree_import_in_tests.patch, + factory_tests.patch, location_testing_script.patch, which are thus + removed. + ------------------------------------------------------------------- Tue Nov 10 07:13:53 UTC 2020 - Matej Cepl diff --git a/python-xmlschema.spec b/python-xmlschema.spec index 6e26ac6..136e214 100644 --- a/python-xmlschema.spec +++ b/python-xmlschema.spec @@ -19,24 +19,15 @@ %{?!python_module:%define python_module() python-%{**} python3-%{**}} %define skip_python2 1 Name: python-xmlschema -Version: 1.3.0 +Version: 1.3.1 Release: 0 Summary: An XML Schema validator and decoder License: MIT URL: https://github.com/sissaschool/xmlschema Source: https://files.pythonhosted.org/packages/source/x/xmlschema/xmlschema-%{version}.tar.gz -# PATCH-FIX-UPSTREAM etree_import_in_tests.patch gh#sissaschool/xmlschema#210 mcepl@suse.com -# use the same etree all the time -Patch0: etree_import_in_tests.patch -# PATCH-FIX-UPSTREAM factory_tests.patch gh#sissaschool/xmlschema#210 mcepl@suse.com -# rename tests_factory to factory_tests so it is not discovered by pytest. -Patch1: factory_tests.patch # PATCH-FIX-UPSTREAM remove_shebang.patch gh#sissaschool/xmlschema#210 mcepl@suse.com # Remove superfluous shebang -Patch2: remove_shebang.patch -# PATCH-FIX-UPSTREAM location_testing_script.patch gh#sissaschool/xmlschema#210 mcepl@suse.com -# this patch makes things totally awesome -Patch3: location_testing_script.patch +Patch0: remove_shebang.patch BuildRequires: %{python_module elementpath >= 1.4.0} BuildRequires: %{python_module lxml} BuildRequires: %{python_module pip} diff --git a/xmlschema-1.3.0.tar.gz b/xmlschema-1.3.0.tar.gz deleted file mode 100644 index d578b85..0000000 --- a/xmlschema-1.3.0.tar.gz +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:638eddd3150b8214397eddeb9402457678b63a343c468a96042f56438b6ff1d8 -size 319713 diff --git a/xmlschema-1.3.1.tar.gz b/xmlschema-1.3.1.tar.gz new file mode 100644 index 0000000..028b398 --- /dev/null +++ b/xmlschema-1.3.1.tar.gz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ef25efd054afe5bbbbe0c5f86f32bd8e8afd566c90986d6b80a2abb8e6a4c46e +size 318853