forked from pool/python-xmlschema
- 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
This commit is contained in:
@@ -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, '<element/>')
|
|
||||||
+ self.assertRaises(TypeError, etree_tostring, '<element/>')
|
|
||||||
|
|
||||||
elem = ElementTree.Element('element')
|
|
||||||
- self.assertEqual(etree.etree_tostring(elem), '<element />')
|
|
||||||
- self.assertEqual(etree.etree_tostring(elem, xml_declaration=True), '<element />')
|
|
||||||
+ self.assertEqual(etree_tostring(elem), '<element />')
|
|
||||||
+ self.assertEqual(etree_tostring(elem, xml_declaration=True), '<element />')
|
|
||||||
|
|
||||||
- self.assertEqual(etree.etree_tostring(elem, encoding='us-ascii'), b'<element />')
|
|
||||||
- self.assertEqual(etree.etree_tostring(elem, encoding='us-ascii', indent=' '),
|
|
||||||
+ self.assertEqual(etree_tostring(elem, encoding='us-ascii'), b'<element />')
|
|
||||||
+ self.assertEqual(etree_tostring(elem, encoding='us-ascii', indent=' '),
|
|
||||||
b' <element />')
|
|
||||||
- self.assertEqual(etree.etree_tostring(elem, encoding='us-ascii', xml_declaration=True),
|
|
||||||
+ self.assertEqual(etree_tostring(elem, encoding='us-ascii', xml_declaration=True),
|
|
||||||
b'<?xml version="1.0" encoding="us-ascii"?>\n<element />')
|
|
||||||
|
|
||||||
- self.assertEqual(etree.etree_tostring(elem, encoding='ascii'),
|
|
||||||
+ self.assertEqual(etree_tostring(elem, encoding='ascii'),
|
|
||||||
b"<?xml version='1.0' encoding='ascii'?>\n<element />")
|
|
||||||
- self.assertEqual(etree.etree_tostring(elem, encoding='ascii', xml_declaration=False),
|
|
||||||
+ self.assertEqual(etree_tostring(elem, encoding='ascii', xml_declaration=False),
|
|
||||||
b'<element />')
|
|
||||||
- self.assertEqual(etree.etree_tostring(elem, encoding='utf-8'), b'<element />')
|
|
||||||
- self.assertEqual(etree.etree_tostring(elem, encoding='utf-8', xml_declaration=True),
|
|
||||||
+ self.assertEqual(etree_tostring(elem, encoding='utf-8'), b'<element />')
|
|
||||||
+ self.assertEqual(etree_tostring(elem, encoding='utf-8', xml_declaration=True),
|
|
||||||
b'<?xml version="1.0" encoding="utf-8"?>\n<element />')
|
|
||||||
|
|
||||||
- self.assertEqual(etree.etree_tostring(elem, encoding='iso-8859-1'),
|
|
||||||
+ self.assertEqual(etree_tostring(elem, encoding='iso-8859-1'),
|
|
||||||
b"<?xml version='1.0' encoding='iso-8859-1'?>\n<element />")
|
|
||||||
- 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"<element />")
|
|
||||||
|
|
||||||
- self.assertEqual(etree.etree_tostring(elem, method='html'), '<element></element>')
|
|
||||||
- self.assertEqual(etree.etree_tostring(elem, method='text'), '')
|
|
||||||
+ self.assertEqual(etree_tostring(elem, method='html'), '<element></element>')
|
|
||||||
+ self.assertEqual(etree_tostring(elem, method='text'), '')
|
|
||||||
|
|
||||||
- root = etree.ElementTree.XML('<root>\n'
|
|
||||||
- ' text1\n'
|
|
||||||
- ' <elem>text2</elem>\n'
|
|
||||||
- '</root>')
|
|
||||||
- self.assertEqual(etree.etree_tostring(root, method='text'), '\n text1\n text2')
|
|
||||||
+ root = ElementTree.XML('<root>\n'
|
|
||||||
+ ' text1\n'
|
|
||||||
+ ' <elem>text2</elem>\n'
|
|
||||||
+ '</root>')
|
|
||||||
+ 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), '<element />')
|
|
||||||
- self.assertEqual(etree.etree_tostring(elem, xml_declaration=True), '<element />')
|
|
||||||
+ elem = PyElementTree.Element('element')
|
|
||||||
+ self.assertEqual(etree_tostring(elem), '<element />')
|
|
||||||
+ self.assertEqual(etree_tostring(elem, xml_declaration=True), '<element />')
|
|
||||||
|
|
||||||
- self.assertEqual(etree.etree_tostring(elem, encoding='us-ascii'), b'<element />')
|
|
||||||
- self.assertEqual(etree.etree_tostring(elem, encoding='us-ascii', xml_declaration=True),
|
|
||||||
+ self.assertEqual(etree_tostring(elem, encoding='us-ascii'), b'<element />')
|
|
||||||
+ self.assertEqual(etree_tostring(elem, encoding='us-ascii', xml_declaration=True),
|
|
||||||
b'<?xml version="1.0" encoding="us-ascii"?>\n<element />')
|
|
||||||
|
|
||||||
- self.assertEqual(etree.etree_tostring(elem, encoding='ascii'),
|
|
||||||
+ self.assertEqual(etree_tostring(elem, encoding='ascii'),
|
|
||||||
b"<?xml version='1.0' encoding='ascii'?>\n<element />")
|
|
||||||
- self.assertEqual(etree.etree_tostring(elem, encoding='ascii', xml_declaration=False),
|
|
||||||
+ self.assertEqual(etree_tostring(elem, encoding='ascii', xml_declaration=False),
|
|
||||||
b'<element />')
|
|
||||||
- self.assertEqual(etree.etree_tostring(elem, encoding='utf-8'), b'<element />')
|
|
||||||
- self.assertEqual(etree.etree_tostring(elem, encoding='utf-8', xml_declaration=True),
|
|
||||||
+ self.assertEqual(etree_tostring(elem, encoding='utf-8'), b'<element />')
|
|
||||||
+ self.assertEqual(etree_tostring(elem, encoding='utf-8', xml_declaration=True),
|
|
||||||
b'<?xml version="1.0" encoding="utf-8"?>\n<element />')
|
|
||||||
|
|
||||||
- self.assertEqual(etree.etree_tostring(elem, encoding='iso-8859-1'),
|
|
||||||
+ self.assertEqual(etree_tostring(elem, encoding='iso-8859-1'),
|
|
||||||
b"<?xml version='1.0' encoding='iso-8859-1'?>\n<element />")
|
|
||||||
- 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"<element />")
|
|
||||||
|
|
||||||
- self.assertEqual(etree.etree_tostring(elem, method='html'), '<element></element>')
|
|
||||||
- self.assertEqual(etree.etree_tostring(elem, method='text'), '')
|
|
||||||
+ self.assertEqual(etree_tostring(elem, method='html'), '<element></element>')
|
|
||||||
+ self.assertEqual(etree_tostring(elem, method='text'), '')
|
|
||||||
|
|
||||||
- root = etree.PyElementTree.XML('<root>\n'
|
|
||||||
- ' text1\n'
|
|
||||||
- ' <elem>text2</elem>\n'
|
|
||||||
- '</root>')
|
|
||||||
- self.assertEqual(etree.etree_tostring(root, method='text'), '\n text1\n text2')
|
|
||||||
+ root = PyElementTree.XML('<root>\n'
|
|
||||||
+ ' text1\n'
|
|
||||||
+ ' <elem>text2</elem>\n'
|
|
||||||
+ '</root>')
|
|
||||||
+ 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), '<element/>')
|
|
||||||
- self.assertEqual(etree.etree_tostring(elem, xml_declaration=True), '<element/>')
|
|
||||||
+ self.assertEqual(etree_tostring(elem), '<element/>')
|
|
||||||
+ self.assertEqual(etree_tostring(elem, xml_declaration=True), '<element/>')
|
|
||||||
|
|
||||||
- self.assertEqual(etree.etree_tostring(elem, encoding='us-ascii'), b'<element/>')
|
|
||||||
- self.assertEqual(etree.etree_tostring(elem, encoding='us-ascii', xml_declaration=True),
|
|
||||||
+ self.assertEqual(etree_tostring(elem, encoding='us-ascii'), b'<element/>')
|
|
||||||
+ self.assertEqual(etree_tostring(elem, encoding='us-ascii', xml_declaration=True),
|
|
||||||
b'<?xml version="1.0" encoding="us-ascii"?>\n<element/>')
|
|
||||||
|
|
||||||
- self.assertEqual(etree.etree_tostring(elem, encoding='ascii'), b'<element/>')
|
|
||||||
- self.assertEqual(etree.etree_tostring(elem, encoding='ascii', xml_declaration=True),
|
|
||||||
+ self.assertEqual(etree_tostring(elem, encoding='ascii'), b'<element/>')
|
|
||||||
+ self.assertEqual(etree_tostring(elem, encoding='ascii', xml_declaration=True),
|
|
||||||
b'<?xml version="1.0" encoding="ascii"?>\n<element/>')
|
|
||||||
|
|
||||||
- self.assertEqual(etree.etree_tostring(elem, encoding='utf-8'), b'<element/>')
|
|
||||||
- self.assertEqual(etree.etree_tostring(elem, encoding='utf-8', xml_declaration=True),
|
|
||||||
+ self.assertEqual(etree_tostring(elem, encoding='utf-8'), b'<element/>')
|
|
||||||
+ self.assertEqual(etree_tostring(elem, encoding='utf-8', xml_declaration=True),
|
|
||||||
b'<?xml version="1.0" encoding="utf-8"?>\n<element/>')
|
|
||||||
|
|
||||||
- self.assertEqual(etree.etree_tostring(elem, encoding='iso-8859-1'),
|
|
||||||
+ self.assertEqual(etree_tostring(elem, encoding='iso-8859-1'),
|
|
||||||
b"<?xml version='1.0' encoding='iso-8859-1'?>\n<element/>")
|
|
||||||
- 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"<element/>")
|
|
||||||
|
|
||||||
- self.assertEqual(etree.etree_tostring(elem, method='html'), '<element></element>')
|
|
||||||
- self.assertEqual(etree.etree_tostring(elem, method='text'), '')
|
|
||||||
+ self.assertEqual(etree_tostring(elem, method='html'), '<element></element>')
|
|
||||||
+ self.assertEqual(etree_tostring(elem, method='text'), '')
|
|
||||||
|
|
||||||
root = lxml.etree.XML('<root>\n'
|
|
||||||
' text1\n'
|
|
||||||
' <elem>text2</elem>\n'
|
|
||||||
'</root>')
|
|
||||||
- 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('<a><b1><c1/><c2/></b1><b2/><b3><c3/></b3></a>')
|
|
||||||
|
|
||||||
- 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('<a><b1><c1/><c2/></b1><b2/><b3><c3/></b3></a>')
|
|
||||||
|
|
||||||
- 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('<a><b1>text<c1 a="1"/></b1>\n<b2/><b3/></a>\n')
|
|
||||||
e2 = ElementTree.XML('<a><b1>text<c1 a="1"/></b1>\n<b2/><b3/></a>\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('<a><b1>text<c1 a="1"/></b1>\n<b2/><b3/></a>\n')
|
|
||||||
- self.assertIsNone(etree.etree_elements_assert_equal(e1, e2))
|
|
||||||
+ self.assertIsNone(etree_elements_assert_equal(e1, e2))
|
|
||||||
|
|
||||||
e2 = ElementTree.XML('<a><b1>text<c1 a="1"/></b1>\n<b2/><b3/><b4/></a>\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 <Element 'a'", str(ctx.exception))
|
|
||||||
|
|
||||||
e2 = ElementTree.XML('<a><b1>text <c1 a="1"/></b1>\n<b2/><b3/></a>\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('<a><b1>text<c1 a="1"/></b1>\n<b2>text</b2><b3/></a>\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('<a><b1>text<c1 a="1"/></b1>\n<b2/><b3/></a>')
|
|
||||||
- self.assertIsNone(etree.etree_elements_assert_equal(e1, e2))
|
|
||||||
+ self.assertIsNone(etree_elements_assert_equal(e1, e2))
|
|
||||||
|
|
||||||
e2 = ElementTree.XML('<a><b1>text<c1 a="1"/></b1><b2/><b3/></a>\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('<a><b1>text<c1 a="1 "/></b1>\n<b2/><b3/></a>\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('<a><b1>text<c1 a="2 "/></b1>\n<b2/><b3/></a>\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('<a><!--comment--><b1>text<c1 a="1"/></b1>\n<b2/><b3/></a>\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('<a><!--comment--><b1>text<c1 a="1"/></b1>\n<b2/><b3/></a>\n')
|
|
||||||
- self.assertIsNone(etree.etree_elements_assert_equal(e1, e2))
|
|
||||||
+ self.assertIsNone(etree_elements_assert_equal(e1, e2))
|
|
||||||
|
|
||||||
e1 = ElementTree.XML('<a><b1>+1</b1></a>')
|
|
||||||
e2 = ElementTree.XML('<a><b1>+ 1 </b1></a>')
|
|
||||||
- self.assertIsNone(etree.etree_elements_assert_equal(e1, e2, strict=False))
|
|
||||||
+ self.assertIsNone(etree_elements_assert_equal(e1, e2, strict=False))
|
|
||||||
|
|
||||||
e1 = ElementTree.XML('<a><b1>+1</b1></a>')
|
|
||||||
e2 = ElementTree.XML('<a><b1>+1.1 </b1></a>')
|
|
||||||
|
|
||||||
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('<a><b1>1</b1></a>')
|
|
||||||
e2 = ElementTree.XML('<a><b1>true </b1></a>')
|
|
||||||
- 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('<a><b1>false </b1></a>')
|
|
||||||
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('<a><b1> 0</b1></a>')
|
|
||||||
- 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('<a><b1>true </b1></a>')
|
|
||||||
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('<a><b1>text<c1 a="1"/></b1>\n<b2/><b3/></a>\n')
|
|
||||||
e2 = ElementTree.XML('<a><b1>text<c1 a="1"/>tail</b1>\n<b2/><b3/></a>\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('<a><b1><c1/><c2/></b1><b2/><b3><c3/></b3></a>')
|
|
||||||
- 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('<a><b1><c1/><c2/></b1><b2/><b3><c3/></b3></a>')
|
|
||||||
- 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 = """
|
|
||||||
- <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
|
|
||||||
+ <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
|
|
||||||
xmlns:vh="http://example.com/vehicles">
|
|
||||||
<xs:import namespace="http://example.com/vehicles" schemaLocation="{}"/>
|
|
||||||
</xs:schema>""".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 = """<?xml version
|
|
||||||
|
|
||||||
WSDL_DOCUMENT_NO_SOAP = """<?xml version="1.0"?>
|
|
||||||
<wsdl:definitions name="minimal"
|
|
||||||
- xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
|
|
||||||
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
|
|
||||||
xmlns:xs="http://www.w3.org/2001/XMLSchema">
|
|
||||||
|
|
||||||
<wsdl:message name="myMessage">
|
|
||||||
@@ -403,7 +401,7 @@ class TestWsdlDocuments(unittest.TestCas
|
|
||||||
|
|
||||||
def test_wsdl_document_invalid_imports(self):
|
|
||||||
wsdl_template = """<?xml version="1.0"?>
|
|
||||||
- <definitions name="import-test1"
|
|
||||||
+ <definitions name="import-test1"
|
|
||||||
xmlns="http://schemas.xmlsoap.org/wsdl/">
|
|
||||||
<import namespace="http://example.com/ns" location="{0}"/>
|
|
||||||
</definitions>"""
|
|
||||||
@@ -427,7 +425,7 @@ class TestWsdlDocuments(unittest.TestCas
|
|
||||||
self.assertIn('no element found', str(ctx.exception))
|
|
||||||
|
|
||||||
wsdl_template = """<?xml version="1.0"?>
|
|
||||||
- <definitions name="import-test1"
|
|
||||||
+ <definitions name="import-test1"
|
|
||||||
targetNamespace="http://example.com/ns"
|
|
||||||
xmlns="http://schemas.xmlsoap.org/wsdl/">
|
|
||||||
<import namespace="http://example.com/ns" location="{0}"/>
|
|
||||||
@@ -439,7 +437,7 @@ class TestWsdlDocuments(unittest.TestCas
|
|
||||||
self.assertIn('namespace to import must be different', str(ctx.exception))
|
|
||||||
|
|
||||||
wsdl_template = """<?xml version="1.0"?>
|
|
||||||
- <definitions name="import-test1"
|
|
||||||
+ <definitions name="import-test1"
|
|
||||||
targetNamespace="http://example.com/stockquote/definitions"
|
|
||||||
xmlns="http://schemas.xmlsoap.org/wsdl/">
|
|
||||||
<import namespace="http://example.com/ns" location="{0}"/>
|
|
||||||
--- 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 <brunato@sissa.it>
|
|
||||||
#
|
|
||||||
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))
|
|
@@ -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.
|
|
||||||
|
|
@@ -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')
|
|
@@ -1,3 +1,11 @@
|
|||||||
|
-------------------------------------------------------------------
|
||||||
|
Tue Nov 10 13:49:08 UTC 2020 - Matej Cepl <mcepl@suse.com>
|
||||||
|
|
||||||
|
- 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 <mcepl@suse.com>
|
Tue Nov 10 07:13:53 UTC 2020 - Matej Cepl <mcepl@suse.com>
|
||||||
|
|
||||||
|
@@ -19,24 +19,15 @@
|
|||||||
%{?!python_module:%define python_module() python-%{**} python3-%{**}}
|
%{?!python_module:%define python_module() python-%{**} python3-%{**}}
|
||||||
%define skip_python2 1
|
%define skip_python2 1
|
||||||
Name: python-xmlschema
|
Name: python-xmlschema
|
||||||
Version: 1.3.0
|
Version: 1.3.1
|
||||||
Release: 0
|
Release: 0
|
||||||
Summary: An XML Schema validator and decoder
|
Summary: An XML Schema validator and decoder
|
||||||
License: MIT
|
License: MIT
|
||||||
URL: https://github.com/sissaschool/xmlschema
|
URL: https://github.com/sissaschool/xmlschema
|
||||||
Source: https://files.pythonhosted.org/packages/source/x/xmlschema/xmlschema-%{version}.tar.gz
|
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
|
# PATCH-FIX-UPSTREAM remove_shebang.patch gh#sissaschool/xmlschema#210 mcepl@suse.com
|
||||||
# Remove superfluous shebang
|
# Remove superfluous shebang
|
||||||
Patch2: remove_shebang.patch
|
Patch0: 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
|
|
||||||
BuildRequires: %{python_module elementpath >= 1.4.0}
|
BuildRequires: %{python_module elementpath >= 1.4.0}
|
||||||
BuildRequires: %{python_module lxml}
|
BuildRequires: %{python_module lxml}
|
||||||
BuildRequires: %{python_module pip}
|
BuildRequires: %{python_module pip}
|
||||||
|
@@ -1,3 +0,0 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
|
||||||
oid sha256:638eddd3150b8214397eddeb9402457678b63a343c468a96042f56438b6ff1d8
|
|
||||||
size 319713
|
|
3
xmlschema-1.3.1.tar.gz
Normal file
3
xmlschema-1.3.1.tar.gz
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
version https://git-lfs.github.com/spec/v1
|
||||||
|
oid sha256:ef25efd054afe5bbbbe0c5f86f32bd8e8afd566c90986d6b80a2abb8e6a4c46e
|
||||||
|
size 318853
|
Reference in New Issue
Block a user