robotframework-xmlvalidator 2.1.0__tar.gz → 2.1.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: robotframework-xmlvalidator
3
- Version: 2.1.0
3
+ Version: 2.1.1
4
4
  Summary: A Robot Framework test library for validating XML files against XSD schemas
5
5
  License: Apache-2.0
6
6
  License-File: LICENSE
@@ -18,7 +18,7 @@ Classifier: Programming Language :: Python :: 3.13
18
18
  Classifier: Programming Language :: Python :: 3.14
19
19
  Classifier: Programming Language :: Python :: 3 :: Only
20
20
  Classifier: Topic :: Software Development :: Testing
21
- Requires-Dist: lxml (>=5.1.0,<6.0.0)
21
+ Requires-Dist: lxml (>=6.1.0,<7.0.0)
22
22
  Requires-Dist: pandas (>=2.2.0,<3.0.0)
23
23
  Requires-Dist: robotframework (>=7.0.0,<8.0.0)
24
24
  Requires-Dist: xmlschema (>=3.4.3,<4.0.0)
@@ -27,10 +27,9 @@ Project-URL: Homepage, https://github.com/MichaelHallik/robotframework-xmlvalida
27
27
  Project-URL: Repository, https://github.com/MichaelHallik/robotframework-xmlvalidator
28
28
  Description-Content-Type: text/markdown
29
29
 
30
- | Version | License | Tests | Downloads |
31
- |---------|---------|-------|-----------|
32
- | [![PyPI version](https://img.shields.io/pypi/v/robotframework-xmlvalidator)](https://pypi.org/project/robotframework-xmlvalidator/) | [![License](https://img.shields.io/github/license/MichaelHallik/robotframework-xmlvalidator)](LICENSE) | [![Tests](https://github.com/MichaelHallik/robotframework-xmlvalidator/actions/workflows/test.yml/badge.svg)](https://github.com/MichaelHallik/robotframework-xmlvalidator/actions) | [![Downloads](https://img.shields.io/pepy/dt/robotframework-xmlvalidator)](https://pepy.tech/project/robotframework-xmlvalidator) |
33
-
30
+ | Version | License | Tests | Downloads - total | Downloads - last 30 days |
31
+ |---------|---------|-------|-------------------|--------------------------|
32
+ | [![PyPI version](https://img.shields.io/pypi/v/robotframework-xmlvalidator)](https://pypi.org/project/robotframework-xmlvalidator/) | [![License](https://img.shields.io/github/license/MichaelHallik/robotframework-xmlvalidator)](LICENSE) | [![Tests](https://github.com/MichaelHallik/robotframework-xmlvalidator/actions/workflows/test.yml/badge.svg)](https://github.com/MichaelHallik/robotframework-xmlvalidator/actions) | [![Downloads](https://img.shields.io/pepy/dt/robotframework-xmlvalidator)](https://pepy.tech/project/robotframework-xmlvalidator) | [![PyPI Downloads](https://static.pepy.tech/personalized-badge/robotframework-xmlvalidator?period=monthly&units=ABBREVIATION&left_color=BLACK&right_color=GREEN&left_text=downloads%2Fmonth)](https://pepy.tech/projects/robotframework-xmlvalidator)
34
33
 
35
34
  <details>
36
35
  <summary><strong>📚 Table of Contents</strong></summary>
@@ -844,3 +843,4 @@ Licensed under the Apache License 2.0. See [LICENSE](LICENSE).
844
843
  ## Author
845
844
 
846
845
  [Michael Hallik](https://www.linkedin.com/in/michaelhallik/)
846
+
@@ -1,7 +1,6 @@
1
- | Version | License | Tests | Downloads |
2
- |---------|---------|-------|-----------|
3
- | [![PyPI version](https://img.shields.io/pypi/v/robotframework-xmlvalidator)](https://pypi.org/project/robotframework-xmlvalidator/) | [![License](https://img.shields.io/github/license/MichaelHallik/robotframework-xmlvalidator)](LICENSE) | [![Tests](https://github.com/MichaelHallik/robotframework-xmlvalidator/actions/workflows/test.yml/badge.svg)](https://github.com/MichaelHallik/robotframework-xmlvalidator/actions) | [![Downloads](https://img.shields.io/pepy/dt/robotframework-xmlvalidator)](https://pepy.tech/project/robotframework-xmlvalidator) |
4
-
1
+ | Version | License | Tests | Downloads - total | Downloads - last 30 days |
2
+ |---------|---------|-------|-------------------|--------------------------|
3
+ | [![PyPI version](https://img.shields.io/pypi/v/robotframework-xmlvalidator)](https://pypi.org/project/robotframework-xmlvalidator/) | [![License](https://img.shields.io/github/license/MichaelHallik/robotframework-xmlvalidator)](LICENSE) | [![Tests](https://github.com/MichaelHallik/robotframework-xmlvalidator/actions/workflows/test.yml/badge.svg)](https://github.com/MichaelHallik/robotframework-xmlvalidator/actions) | [![Downloads](https://img.shields.io/pepy/dt/robotframework-xmlvalidator)](https://pepy.tech/project/robotframework-xmlvalidator) | [![PyPI Downloads](https://static.pepy.tech/personalized-badge/robotframework-xmlvalidator?period=monthly&units=ABBREVIATION&left_color=BLACK&right_color=GREEN&left_text=downloads%2Fmonth)](https://pepy.tech/projects/robotframework-xmlvalidator)
5
4
 
6
5
  <details>
7
6
  <summary><strong>📚 Table of Contents</strong></summary>
@@ -814,4 +813,4 @@ Licensed under the Apache License 2.0. See [LICENSE](LICENSE).
814
813
 
815
814
  ## Author
816
815
 
817
- [Michael Hallik](https://www.linkedin.com/in/michaelhallik/)
816
+ [Michael Hallik](https://www.linkedin.com/in/michaelhallik/)
@@ -1,7 +1,7 @@
1
1
  # General.
2
2
  [tool.poetry]
3
3
  name = "robotframework-xmlvalidator"
4
- version = "2.1.0"
4
+ version = "2.1.1"
5
5
  description = "A Robot Framework test library for validating XML files against XSD schemas"
6
6
  authors = ["Michael Hallik <hallik.michael@gmail.com>"]
7
7
  license = "Apache-2.0"
@@ -24,17 +24,17 @@ classifiers = [
24
24
  # Package installation dependencies.
25
25
  [tool.poetry.dependencies]
26
26
  python = ">=3.10"
27
- lxml = "^5.1.0"
27
+ lxml = "^6.1.0"
28
28
  pandas = "^2.2.0"
29
29
  robotframework = "^7.0.0"
30
30
  xmlschema = "^3.4.3"
31
31
 
32
32
  # Development dependencies (not installed during normal package installation).
33
33
  [tool.poetry.group.dev.dependencies]
34
- black = "^25.1.0"
34
+ black = "^26.3.1"
35
35
  pylint = "^3.1.0"
36
36
  pyright = "^1.1.357"
37
- pytest = "^8.3.1" # Needed for unit testing.
37
+ pytest = "^9.0.3" # Needed for unit testing.
38
38
  pytest-mock = "^3.12.0" # Needed for mocking in tests.
39
39
  pytest-cov = "^4.1.0"
40
40
 
@@ -47,4 +47,4 @@ build-backend = "poetry.core.masonry.api" # The Poetry module which handles pack
47
47
  [tool.pytest.ini_options]
48
48
  minversion = "6.0"
49
49
  addopts = "-ra --strict-markers"
50
- testpaths = ["test/unit"]
50
+ testpaths = ["test/unit"]
@@ -16,12 +16,12 @@
16
16
 
17
17
 
18
18
  """
19
- This module defines the `XmlValidator` class — a Robot Framework test
20
- library for validating XML files against XSD schemas using the
19
+ This module defines the `XmlValidator` class — a Robot Framework test
20
+ library for validating XML files against XSD schemas using the
21
21
  `xmlschema` library.
22
22
 
23
- The validator supports both individual and batch validation workflows,
24
- with comprehensive error reporting and optional export to structured
23
+ The validator supports both individual and batch validation workflows,
24
+ with comprehensive error reporting and optional export to structured
25
25
  CSV files.
26
26
 
27
27
  Key Features:
@@ -35,7 +35,7 @@ Key Features:
35
35
  - Graceful handling of malformed XML or XSD files.
36
36
  - Optional export of all collected errors to a CSV file.
37
37
 
38
- This module is intended to be imported by Robot Framework test suites
38
+ This module is intended to be imported by Robot Framework test suites
39
39
  or executed as a Python module via a direct call.
40
40
  """
41
41
 
@@ -43,42 +43,47 @@ or executed as a Python module via a direct call.
43
43
  # pylint: disable=C0103:invalid-name # On account of the module name, that is not snake-cased (required by Robot Framework).
44
44
  # pylint: disable=C0302:too-many-lines # On account of the extensive docstrings and annotations.
45
45
  # pylint: disable=C0301:line-too-long # On account of tables in docstrings.
46
-
46
+ # ruff: noqa: W291 # Temporary: needs to be fixed.
47
+ # ruff: noqa: W293 # Temporary: needs to be fixed.
48
+ # ruff: noqa: E501 # Temporary: needs to be fixed.
47
49
 
48
50
  # Standard library imports.
49
51
  from pathlib import Path
50
- from typing import Any, Dict, List, Literal, Optional, Tuple
52
+ from typing import Any, Literal
53
+
51
54
  # Third party library imports.
52
55
  from lxml import etree
53
56
  from robot.api import Failure, logger
54
57
  from robot.api.deco import keyword, library
55
58
  from xmlschema import XMLSchema
59
+
56
60
  # Local application imports.
57
- from .xml_validator_results import ValidatorResultRecorder, ValidatorResult
61
+ from ._version import __version__
62
+ from .xml_validator_results import ValidatorResult, ValidatorResultRecorder
58
63
  from .xml_validator_utils import ValidatorUtils
59
64
 
60
65
 
61
- @library(scope='GLOBAL')
66
+ @library(scope='GLOBAL', version=__version__, doc_format="REST")
62
67
  class XmlValidator:
63
68
  """
64
- XmlValidator is a `Robot Framework <https://robotframework.org/>`_
69
+ XmlValidator is a `Robot Framework <https://robotframework.org/>`_
65
70
  test library for validating XML files against XSD schemas.
66
71
 
67
- The library leverages the power of the
68
- `xmlschema library <https://pypi.org/project/xmlschema/>`_ and is
72
+ The library leverages the power of the
73
+ `xmlschema library <https://pypi.org/project/xmlschema/>`_ and is
69
74
  designed for both single-file and batch XML validation workflows.
70
75
 
71
- It provides structured and detailed reporting of XML parse errors
72
- (malformed XML content) and XSD violations, schema auto-detection
76
+ It provides structured and detailed reporting of XML parse errors
77
+ (malformed XML content) and XSD violations, schema auto-detection
73
78
  and CSV exports of collected errors.
74
79
 
75
- Features are described in detail on the `project repo's landing page.
80
+ Features are described in detail on the `project repo's landing page.
76
81
  <https://github.com/MichaelHallik/robotframework-xmlvalidator>`_.
77
82
 
78
83
  **Overview**
79
-
84
+
80
85
  The main keyword is ``Validate Xml Files``.
81
-
86
+
82
87
  The other keywords are convenience/helper functions, e.g. ``Reset
83
88
  Error Facets``.
84
89
 
@@ -393,15 +398,13 @@ class XmlValidator:
393
398
 
394
399
  """
395
400
 
396
- __version__ = '2.1.0'
397
- ROBOT_LIBRARY_DOC_FORMAT = 'reST'
398
401
  nr_instances = 0
399
402
 
400
403
  def __init__(
401
404
  self,
402
405
  xsd_path: str | Path | None = None,
403
406
  base_url: str | None = None,
404
- error_facets: List[str] | None = None,
407
+ error_facets: list[str] | None = None,
405
408
  fail_on_errors: bool = True,
406
409
  ) -> None:
407
410
  """
@@ -595,13 +598,11 @@ class XmlValidator:
595
598
 
596
599
  def _determine_validations(
597
600
  self,
598
- xml_paths: List[Path],
599
- xsd_path: Optional[str|Path] = None,
600
- xsd_search_strategy: Optional[
601
- Literal['by_namespace', 'by_file_name']
602
- ] = None,
603
- base_url: Optional[str] = None
604
- ) -> Dict[Path, Path | None]:
601
+ xml_paths: list[Path],
602
+ xsd_path: str | Path | None = None,
603
+ xsd_search_strategy: Literal['by_namespace', 'by_file_name'] | None = None,
604
+ base_url: str | None = None
605
+ ) -> dict[Path, Path | None]:
605
606
  """
606
607
  Constructs a mapping between XML files and the XSD schemas to
607
608
  use for their validation.
@@ -714,10 +715,10 @@ class XmlValidator:
714
715
  f"Loading of schema failed: {result.error}."
715
716
  )
716
717
  # Ensure downstream schema loading will be skipped.
717
- xsd_file_paths: List[Path|None] = [None] * len(xml_paths)
718
+ xsd_file_paths: list[Path | None] = [None] * len(xml_paths)
718
719
  # Create the XML/XSD map.
719
720
  validations = dict(
720
- zip( xml_paths, xsd_file_paths )
721
+ zip( xml_paths, xsd_file_paths, strict=True )
721
722
  )
722
723
  # We got a set of XSDs, that need to be dynamically mapped to XMLs.
723
724
  else:
@@ -733,17 +734,17 @@ class XmlValidator:
733
734
  # Ensure default schema is loaded; raises exception otherwise.
734
735
  result = self._ensure_schema(None, None)
735
736
  # Ensure downstream schema loading will now be skipped.
736
- xsd_file_paths: List[Path|None] = [None] * len(xml_paths)
737
+ xsd_file_paths: list[Path | None] = [None] * len(xml_paths)
737
738
  # Create the XML/XSD map.
738
739
  validations = dict(
739
- zip( xml_paths, xsd_file_paths )
740
+ zip( xml_paths, xsd_file_paths, strict=True )
740
741
  )
741
742
  return validations
742
743
 
743
744
  def _ensure_schema(
744
745
  self,
745
- xsd_path: Optional[Path] = None,
746
- base_url: Optional[str] = None
746
+ xsd_path: Path | None = None,
747
+ base_url: str | None = None
747
748
  ) -> ValidatorResult:
748
749
  """
749
750
  Ensures that a schema is available for validation.
@@ -827,11 +828,11 @@ class XmlValidator:
827
828
 
828
829
  def _find_schemas(
829
830
  self,
830
- xml_file_paths: List[Path],
831
- xsd_file_paths: List[Path],
831
+ xml_file_paths: list[Path],
832
+ xsd_file_paths: list[Path],
832
833
  search_by: Literal['by_namespace', 'by_file_name'] = 'by_namespace',
833
- base_url: Optional[str] = None
834
- ) -> Dict[ Path, Path | None ]:
834
+ base_url: str | None = None
835
+ ) -> dict[Path, Path | None]:
835
836
  """
836
837
  Finds matching XSD schemas for XML files using the specified
837
838
  search strategy.
@@ -886,7 +887,7 @@ class XmlValidator:
886
887
  to loading or parsing errors.
887
888
 
888
889
  Notes:
889
-
890
+
890
891
  - This method does not perform validation — it only establishes
891
892
  schema associations, which are later consumed by
892
893
  `_validate_xml()`.
@@ -978,7 +979,7 @@ class XmlValidator:
978
979
  def _load_schema(
979
980
  self,
980
981
  xsd_path: Path,
981
- base_url: Optional[str] = None
982
+ base_url: str | None = None
982
983
  ) -> ValidatorResult:
983
984
  """
984
985
  This method is responsible for initializing a schema object,
@@ -1032,8 +1033,8 @@ class XmlValidator:
1032
1033
 
1033
1034
  def _try_load_initial_schema(
1034
1035
  self,
1035
- xsd_path: Optional[str|Path] = None,
1036
- base_url: Optional[str] = None
1036
+ xsd_path: str | Path | None = None,
1037
+ base_url: str | None = None
1037
1038
  ) -> None:
1038
1039
  """
1039
1040
  Attempts to resolve, validate, and load a single XSD schema from
@@ -1112,13 +1113,13 @@ class XmlValidator:
1112
1113
  def _validate_xml( # pylint: disable=R0913:too-many-arguments disable=R0917:too-many-positional-arguments
1113
1114
  self,
1114
1115
  xml_file_path: Path,
1115
- xsd_file_path: Optional[Path] = None,
1116
- base_url: Optional[str] = None,
1117
- error_facets: Optional[ List[str] ] = None,
1118
- pre_parse: Optional[bool] = True
1119
- ) -> Tuple[
1116
+ xsd_file_path: Path | None = None,
1117
+ base_url: str | None = None,
1118
+ error_facets: list[str] | None = None,
1119
+ pre_parse: bool = True
1120
+ ) -> tuple[
1120
1121
  bool,
1121
- Optional[List[dict[str, Any]]]
1122
+ list[dict[str, Any]] | None
1122
1123
  ]:
1123
1124
  """
1124
1125
  Validates an XML file against the currently loaded or provided
@@ -1309,7 +1310,7 @@ class XmlValidator:
1309
1310
  return (True, None) if len(errors) == 0 else (False, errors)
1310
1311
 
1311
1312
  @keyword
1312
- def get_error_facets(self) -> List[str]:
1313
+ def get_error_facets(self) -> list[str]:
1313
1314
  """
1314
1315
  .. raw:: html
1315
1316
 
@@ -1333,7 +1334,7 @@ class XmlValidator:
1333
1334
 
1334
1335
  @keyword
1335
1336
  def get_schema(self,return_schema_name: bool = True
1336
- ) -> Optional[str|XMLSchema]:
1337
+ ) -> str | XMLSchema | None:
1337
1338
  """
1338
1339
  .. raw:: html
1339
1340
 
@@ -1450,20 +1451,18 @@ class XmlValidator:
1450
1451
  def validate_xml_files( # pylint: disable=R0913:too-many-arguments disable=R0914:too-many-locals disable=R0917:too-many-positional-arguments
1451
1452
  self,
1452
1453
  xml_path: str | Path,
1453
- xsd_path: Optional[str | Path] = None,
1454
- xsd_search_strategy: Optional[
1455
- Literal['by_namespace', 'by_file_name']
1456
- ] = None,
1457
- base_url: Optional[str] = None,
1458
- error_facets: Optional[ List[str] ] = None,
1459
- pre_parse: Optional[bool] = True,
1460
- write_to_csv: Optional[bool] = True,
1461
- timestamped: Optional[bool] = True,
1454
+ xsd_path: str | Path | None = None,
1455
+ xsd_search_strategy: Literal['by_namespace', 'by_file_name'] | None = None,
1456
+ base_url: str | None = None,
1457
+ error_facets: list[str] | None = None,
1458
+ pre_parse: bool = True,
1459
+ write_to_csv: bool | None = True,
1460
+ timestamped: bool | None = True,
1462
1461
  reset_errors: bool = True,
1463
- fail_on_errors: Optional[bool] = None,
1464
- error_table: Optional[bool] = True
1465
- ) -> Tuple[
1466
- List[ Dict[str, Any] ],
1462
+ fail_on_errors: bool | None = None,
1463
+ error_table: bool | None = True
1464
+ ) -> tuple[
1465
+ list[dict[str, Any]],
1467
1466
  str | None
1468
1467
  ]:
1469
1468
  """
@@ -0,0 +1,47 @@
1
+ # Copyright 2024-2026 Michael Hallik
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ #
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
13
+ # implied.
14
+ #
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+
18
+
19
+ """
20
+ Package entry point, exposing the XmlValidator class directly at
21
+ the package level.
22
+
23
+ Provides versioning metadata for use in documentation and automation.
24
+
25
+ Features:
26
+
27
+ - Defines the public API (__all__ + aliasing).
28
+ - Simplifies imports by exposing XmlValidator at the top level.
29
+ - Supports dynamic version discovery from installed metadata.
30
+ """
31
+
32
+
33
+ # pylint: disable=C0103:invalid-name # On account of the class name, which is not snake-cased (required by RF).
34
+
35
+
36
+ # Expose the package version.
37
+ from ._version import __version__
38
+
39
+ # Expose XmlValidator class directly for cleaner imports.
40
+ from .XmlValidator import XmlValidator
41
+
42
+ # Alias (i.e. make available) 'XmlValidator' at the package level.
43
+ xmlvalidator = XmlValidator
44
+
45
+ # Define package metadata.
46
+ __all__ = ["XmlValidator", "__version__"]
47
+ __author__ = "Michael Hallik"
@@ -0,0 +1,31 @@
1
+ # Copyright 2024-2026 Michael Hallik
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ #
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
13
+ # implied.
14
+ #
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+
18
+
19
+ """
20
+ Provides the package version from installed package metadata.
21
+ """
22
+
23
+
24
+ import warnings
25
+ from importlib.metadata import PackageNotFoundError, version
26
+
27
+ try:
28
+ __version__ = version("robotframework-xmlvalidator")
29
+ except PackageNotFoundError:
30
+ __version__ = "0.0.0"
31
+ warnings.warn("Package metadata not found, using fallback version.")