Skip to content

Commit

Permalink
Bump bugfix release
Browse files Browse the repository at this point in the history
  - Fix failing URL normalization tests (issue #416)
  - Disable protocols checking with elementpath v4.5.0 (the latest
    extension on attribute protocols broken the compatibility with
    XSD attributes/attribute groups)
  - Fix tests that fail if executed from another path
  • Loading branch information
Davide Brunato committed Sep 12, 2024
1 parent 388b584 commit cadd70a
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 19 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
CHANGELOG
*********

`v3.4.1`_ (2024-09-12)
======================
* Fix failing URL normalization tests (issue #416)
* Disable protocols checking with elementpath v4.5.0

`v3.4.0`_ (2024-09-10)
======================
* Extended ModelVisitor to make it usable as an helper class for generating content
Expand Down Expand Up @@ -715,3 +720,4 @@ v0.9.6 (2017-05-05)
.. _v3.3.1: https://github.com/brunato/xmlschema/compare/v3.3.0...v3.3.1
.. _v3.3.2: https://github.com/brunato/xmlschema/compare/v3.3.1...v3.3.2
.. _v3.4.0: https://github.com/brunato/xmlschema/compare/v3.3.2...v3.4.0
.. _v3.4.1: https://github.com/brunato/xmlschema/compare/v3.4.0...v3.4.1
2 changes: 1 addition & 1 deletion doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
# The short X.Y version.
version = '3.4'
# The full version, including alpha/beta/rc tags.
release = '3.4.0'
release = '3.4.1'

# 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: '2024-09-10'
softwareVersion: v3.4.0
releaseDate: '2024-09-12'
softwareVersion: v3.4.1
developmentStatus: stable
platforms:
- linux
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

setup(
name='xmlschema',
version='3.4.0',
version='3.4.1',
packages=find_packages(include=['xmlschema*']),
package_data={
'xmlschema': ['py.typed', 'locale/**/*.mo', 'locale/**/*.po', 'schemas/*/*.xsd'],
Expand Down
14 changes: 13 additions & 1 deletion tests/test_locations.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,18 @@ def filter_windows_path(path):
return path


def has_fix_for_issue_67673():
"""
Checks if urlunsplit() has the fix for URIs with path starting with multiple
slashes and no authority.
https://github.com/python/cpython/issues/67693
https://github.com/python/cpython/commit/2fa5d70
"""
unc_path = '////netloc/path/file.txt'
return urlsplit(unc_path).geturl() == unc_path


class TestLocations(unittest.TestCase):

@classmethod
Expand Down Expand Up @@ -318,7 +330,7 @@ def test_normalize_url_slashes(self):
self.assertRegex(normalize_url('/root/dir1/schema.xsd'),
f'file://{DRIVE_REGEX}/root/dir1/schema.xsd')

if sys.version_info < (3, 12, 4):
if not has_fix_for_issue_67673():
self.assertRegex(normalize_url('////root/dir1/schema.xsd'),
f'file://{DRIVE_REGEX}//root/dir1/schema.xsd')
self.assertRegex(normalize_url('dir2/schema.xsd', '////root/dir1'),
Expand Down
3 changes: 3 additions & 0 deletions tests/test_typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
except ImportError:
lxml_stubs_module = None

import elementpath


@unittest.skipIf(mypy_api is None, "mypy is not installed")
@unittest.skipIf(lxml_stubs_module is None, "lxml-stubs is not installed")
Expand Down Expand Up @@ -52,6 +54,7 @@ def test_simple_types(self):
])
self.assertEqual(result[2], 0, msg=result[1] or result[0])

@unittest.skipIf(elementpath.__version__ == '4.5.0', "ep450 needs a patch for protocols")
def test_protocols(self):
result = mypy_api.run([
'--strict',
Expand Down
29 changes: 16 additions & 13 deletions tests/validators/test_complex_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#
import unittest
import warnings
from pathlib import Path
from textwrap import dedent
from xml.etree.ElementTree import Element

Expand All @@ -20,6 +21,8 @@

class TestXsdComplexType(XsdValidatorTestCase):

TEST_CASES_DIR = str(Path(__file__).parent.joinpath('../test_cases').resolve())

def check_complex_restriction(self, base, restriction, expected=None, **kwargs):
content = 'complex' if self.content_pattern.search(base) else 'simple'
source = """
Expand Down Expand Up @@ -591,36 +594,36 @@ def test_mixed_content_extension__issue_337(self):

def test_mixed_content_extension__issue_414(self):
# Not a bug, the user refers to an old version (v1.10), but
# there is a detailed analysis about that:
# there is a detailed analysis on that:
# https://stackoverflow.com/a/78942158/1838607
xsd_file = self.casepath('tests/test_cases/issues/issue_414/issue_414.xsd')
xml_file = self.casepath('tests/test_cases/issues/issue_414/issue_414.xml')
xsd_file = self.casepath('issues/issue_414/issue_414.xsd')
xml_file = self.casepath('issues/issue_414/issue_414.xml')

schema = self.schema_class(xsd_file)
self.assertTrue(schema.types['mixedElement'].mixed)
self.assertTrue(schema.elements['root'].type.mixed)
self.assertTrue(schema.is_valid(xml_file))

xsd_file = self.casepath('tests/test_cases/issues/issue_414/issue_414b.xsd')
xsd_file = self.casepath('issues/issue_414/issue_414b.xsd')
schema = self.schema_class(xsd_file)
self.assertTrue(schema.types['mixedElement'].mixed)
self.assertTrue(schema.elements['root'].type.mixed)
self.assertTrue(schema.is_valid(xml_file))

xsd_file = self.casepath('tests/test_cases/issues/issue_414/issue_414ne.xsd')
xsd_file = self.casepath('issues/issue_414/issue_414ne.xsd')
schema = self.schema_class(xsd_file)
self.assertTrue(schema.types['mixedElement'].mixed)
self.assertTrue(schema.elements['root'].type.mixed)

xsd_file = self.casepath('tests/test_cases/issues/issue_414/issue_414ne-inv1.xsd')
xsd_file = self.casepath('issues/issue_414/issue_414ne-inv1.xsd')
with self.assertRaises(XMLSchemaParseError) as ctx:
self.schema_class(xsd_file)

reason = ("base has a different content type (mixed=True) "
"and the extension group is not empty")
self.assertIn(reason, str(ctx.exception))

xsd_file = self.casepath('tests/test_cases/issues/issue_414/issue_414ne-inv2.xsd')
xsd_file = self.casepath('issues/issue_414/issue_414ne-inv2.xsd')
with self.assertRaises(XMLSchemaParseError) as ctx:
self.schema_class(xsd_file)

Expand Down Expand Up @@ -807,7 +810,7 @@ def test_complex_type_assertion(self):

def test_rooted_expression_in_assertion__issue_386(self):
# absolute expression in assertion
xsd_file = self.casepath('tests/test_cases/issues/issue_386/issue_386.xsd')
xsd_file = self.casepath('issues/issue_386/issue_386.xsd')

with warnings.catch_warnings(record=True) as ctx:
self.schema_class(xsd_file)
Expand All @@ -816,18 +819,18 @@ def test_rooted_expression_in_assertion__issue_386(self):
self.assertEqual(len(ctx), 2, "Expected two assert warnings")
self.assertIn("absolute location path", str(ctx[0].message))

xml_file = self.casepath('tests/test_cases/issues/issue_386/issue_386-1.xml')
xml_file = self.casepath('issues/issue_386/issue_386-1.xml')
self.assertFalse(schema.is_valid(xml_file))
xml_file = self.casepath('tests/test_cases/issues/issue_386/issue_386-2.xml')
xml_file = self.casepath('issues/issue_386/issue_386-2.xml')
self.assertFalse(schema.is_valid(xml_file))

# relative path in assertion
xsd_file = self.casepath('tests/test_cases/issues/issue_386/issue_386-2.xsd')
xsd_file = self.casepath('issues/issue_386/issue_386-2.xsd')
schema = XMLSchema11(xsd_file)

xml_file = self.casepath('tests/test_cases/issues/issue_386/issue_386-1.xml')
xml_file = self.casepath('issues/issue_386/issue_386-1.xml')
self.assertTrue(schema.is_valid(xml_file))
xml_file = self.casepath('tests/test_cases/issues/issue_386/issue_386-2.xml')
xml_file = self.casepath('issues/issue_386/issue_386-2.xml')
self.assertFalse(schema.is_valid(xml_file))

def test_sequence_extension(self):
Expand Down
2 changes: 1 addition & 1 deletion xmlschema/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
XMLSchema, XMLSchema10, XMLSchema11, XsdComponent, XsdType, XsdElement, XsdAttribute
)

__version__ = '3.4.0'
__version__ = '3.4.1'
__author__ = "Davide Brunato"
__contact__ = "[email protected]"
__copyright__ = "Copyright 2016-2024, SISSA"
Expand Down

0 comments on commit cadd70a

Please sign in to comment.