diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 298b0f86..ded19943 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -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 @@ -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 diff --git a/doc/conf.py b/doc/conf.py index 09ba5524..b5d7d345 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -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. diff --git a/publiccode.yml b/publiccode.yml index cb608c8d..134821bb 100644 --- a/publiccode.yml +++ b/publiccode.yml @@ -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 diff --git a/setup.py b/setup.py index 38ab7d83..477a4789 100755 --- a/setup.py +++ b/setup.py @@ -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'], diff --git a/tests/test_locations.py b/tests/test_locations.py index 38acf8aa..53452ddb 100644 --- a/tests/test_locations.py +++ b/tests/test_locations.py @@ -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 @@ -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'), diff --git a/tests/test_typing.py b/tests/test_typing.py index 1dc56caf..4d08e47f 100644 --- a/tests/test_typing.py +++ b/tests/test_typing.py @@ -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") @@ -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', diff --git a/tests/validators/test_complex_types.py b/tests/validators/test_complex_types.py index 073e2dce..0bb8a72e 100644 --- a/tests/validators/test_complex_types.py +++ b/tests/validators/test_complex_types.py @@ -10,6 +10,7 @@ # import unittest import warnings +from pathlib import Path from textwrap import dedent from xml.etree.ElementTree import Element @@ -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 = """ @@ -591,28 +594,28 @@ 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) @@ -620,7 +623,7 @@ def test_mixed_content_extension__issue_414(self): "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) @@ -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) @@ -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): diff --git a/xmlschema/__init__.py b/xmlschema/__init__.py index 44bfc05a..46d6da03 100644 --- a/xmlschema/__init__.py +++ b/xmlschema/__init__.py @@ -33,7 +33,7 @@ XMLSchema, XMLSchema10, XMLSchema11, XsdComponent, XsdType, XsdElement, XsdAttribute ) -__version__ = '3.4.0' +__version__ = '3.4.1' __author__ = "Davide Brunato" __contact__ = "brunato@sissa.it" __copyright__ = "Copyright 2016-2024, SISSA"