Skip to content

Commit

Permalink
Include tests from PR #253 and update to release v1.6.4
Browse files Browse the repository at this point in the history
  • Loading branch information
brunato committed Jun 9, 2021
2 parents 160c9a0 + 27e4c5f commit 1d5437e
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 5 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
CHANGELOG
*********

`v1.6.4`_ (2021-06-09)
======================
* Add testing config for Python 3.10 (Tox and CI)
* Fix internal _PurePath class with Python 3.10 (issue #251)
* Remove redundant xmlns="" declaration when encoding with lxml (issue #252)

`v1.6.3`_ (2021-06-07)
======================
* Refactor normalize_url() using pathlib.PurePath
Expand Down Expand Up @@ -450,3 +456,4 @@ v0.9.6 (2017-05-05)
.. _v1.6.1: https://github.com/brunato/xmlschema/compare/v1.6.0...v1.6.1
.. _v1.6.2: https://github.com/brunato/xmlschema/compare/v1.6.1...v1.6.2
.. _v1.6.3: https://github.com/brunato/xmlschema/compare/v1.6.2...v1.6.3
.. _v1.6.4: https://github.com/brunato/xmlschema/compare/v1.6.3...v1.6.4
2 changes: 1 addition & 1 deletion doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
# The short X.Y version.
version = '1.6'
# The full version, including alpha/beta/rc tags.
release = '1.6.4rc1'
release = '1.6.4'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
4 changes: 2 additions & 2 deletions publiccode.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ publiccodeYmlVersion: '0.2'
name: xmlschema
url: 'https://github.com/sissaschool/xmlschema'
landingURL: 'https://github.com/sissaschool/xmlschema'
releaseDate: '2021-06-07'
softwareVersion: v1.6.3
releaseDate: '2021-06-09'
softwareVersion: v1.6.4
developmentStatus: stable
platforms:
- linux
Expand Down
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

setup(
name='xmlschema',
version='1.6.4rc1',
version='1.6.4',
packages=find_packages(include=['xmlschema', 'xmlschema.*']),
include_package_data=True,
entry_points={
Expand Down Expand Up @@ -57,6 +57,7 @@
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: Implementation :: CPython',
'Programming Language :: Python :: Implementation :: PyPy',
'Topic :: Software Development :: Libraries',
Expand Down
57 changes: 57 additions & 0 deletions tests/validation/test_encoding.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@
import unittest
from textwrap import dedent

try:
import lxml.etree as lxml_etree
except ImportError:
lxml_etree = None

from elementpath import datatypes

from xmlschema import XMLSchemaEncodeError, XMLSchemaValidationError
Expand Down Expand Up @@ -595,6 +600,58 @@ def test_encode_sub_tree(self):
)
)

@unittest.skipIf(lxml_etree is None, "The lxml library is not available.")
def test_lxml_encode(self):
"""Test encode with etree_element_class=lxml.etree.Element"""
xd = {
"@xmlns:col": "http://example.com/ns/collection",
"@xmlns:xsi": "http://www.w3.org/2001/XMLSchema-instance",
"@xsi:schemaLocation": "http://example.com/ns/collection collection.xsd",
"object": [
{
"@id": "b0836217463",
"@available": True,
"position": 2,
"title": None,
"year": "1925",
"author": {
"@id": "JM",
"name": "Joan Miró",
"born": "1893-04-20",
"dead": "1983-12-25",
"qualification": "painter, sculptor and ceramicist",
},
},
],
}

elem = self.col_schema.encode(
xd,
path="./col:collection",
namespaces=self.col_namespaces,
etree_element_class=lxml_etree.Element,
)

self.assertEqual(
etree_tostring(elem, namespaces=self.col_namespaces),
dedent(
"""\
<col:collection xmlns:col="http://example.com/ns/collection" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://example.com/ns/collection collection.xsd">
<object id="b0836217463" available="true">
<position>2</position>
<title/>
<year>1925</year>
<author id="JM">
<name>Joan Miró</name>
<born>1893-04-20</born>
<dead>1983-12-25</dead>
<qualification>painter, sculptor and ceramicist</qualification>
</author>
</object>
</col:collection>"""
)
)


class TestEncoding11(TestEncoding):
schema_class = XMLSchema11
Expand Down
2 changes: 1 addition & 1 deletion xmlschema/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
XsdComponent, XsdType, XsdElement, XsdAttribute
)

__version__ = '1.6.4rc1'
__version__ = '1.6.4'
__author__ = "Davide Brunato"
__contact__ = "brunato@sissa.it"
__copyright__ = "Copyright 2016-2021, SISSA"
Expand Down

0 comments on commit 1d5437e

Please sign in to comment.