--- id: xmlunittest version: "1.0.1" license: MIT license_treatment: permissive maintenance: dormant --- # xmlunittest — Library using lxml and unittest for unit testing XML. License: permissive · Maintenance: dormant · Downloads: 1.0M/mo ## What it is and what it does xmlunittest is a TestCase subclass that adds assertion methods for validating XML documents as structured data rather than raw strings. It uses lxml and XPath to let you write tests that check namespaces, element values, attribute presence, and document structure without being brittle to formatting changes or attribute reordering. You extend XmlTestCase, call assertXmlDocument() to parse your XML, then use methods like assertXpathValues(), assertXmlNamespace(), and assertXpathsUniqueValue() to validate specific parts of the tree. This is useful when your code generates XML and you want tests that survive cosmetic changes to the output while still catching structural problems. Use it for: - Test XML output from code that generates configuration files, RSS feeds, or SOAP responses without brittle string comparisons. - Validate that XML documents conform to expected namespaces and element structures using XPath queries. - Check that optional XML elements and attributes are present or absent as expected in unit tests. - Ensure attribute values match a set of allowed options across multiple elements in a single assertion. - Verify uniqueness constraints on XML attributes across a document tree using XPath expressions. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Extends Python's unittest framework to compare XML documents structurally using XPath expressions and lxml, rather than comparing raw XML strings. Yes, if you generate XML and use unittest. The package is stable, has no known vulnerabilities, and low install friction. Dormant maintenance is a minor concern—it suggests no active development, but the core functionality is straightforward and unlikely to break. Use it when string-based XML comparison would be fragile or unreadable. ## Install pip install xmlunittest uv add xmlunittest poetry add xmlunittest ## Installing xmlunittest Before you install: Low friction: pure Python wheel with a single runtime dependency on lxml. Maintenance is dormant (762 days since last release) but the repository is not archived and the package is marked Production/Stable. License in practice: MIT license is permissive; you can use this package freely in commercial and private projects with minimal restrictions. Quickstart: from xmlunittest import XmlTestCase class MyTest(XmlTestCase): def test_xml(self): data = b'' root = self.assertXmlDocument(data) self.assertXpathValues(root, './item/@id', ('1',)) Requires lxml to be installed; lxml has C dependencies that may need compilation on some platforms. Verify before relying: - Whether the package works with Python 3.13+ (classifiers list only up to 3.12) - Whether dormant maintenance status affects real-world bug fixes or security updates going forward ## Package facts - License: MIT (permissive) - Python support: supports_current - Install friction: low - Maintenance: dormant - Downloads: 1.0M/month (top 5,000 on PyPI) - Known vulnerabilities: none known ## Tags xml unit testing, xpath assertions, xml document comparison, unittest xml validation, lxml test helpers, xml schema testing, structured xml testing, xml-testing, xpath-assertions [View on SkillFed](https://skillfed.io/packages/xmlunittest) · [View on PyPI](https://pypi.org/project/xmlunittest/)