Library using lxml and unittest for unit testing XML. This is an actively maintained and PEP8 compliant fork of xmlunittest.
Project description
Python XML-Unittest
===================
[![Build Status](https://travis-ci.org/richardasaurus/python-xmlunittest-better.png?branch=master)](https://travis-ci.org/richardasaurus/python-xmlunittest-better)
[![Downloads](https://pypip.in/d/xmlunittestbetter/badge.png)](https://crate.io/packages/xmlunittestbetter/)
This is a spork of [https://github.com/Exirel/python-xmlunittest](https://github.com/Exirel/python-xmlunittest).
With wider lxml support and Python 2.7, 3.4 & 3.4 support.
Examples
======
- Extend xmlunittest.XmlTestCase
- Write your tests, using the function or method that generate XML document
- Use xmlunittest.XmlTestCase‘s assertion methods to validate
- Keep your test readable
Example:
```
from xmlunittest import XmlTestCase
class CustomTestCase(XmlTestCase):
def test_my_custom_test(self):
# In a real case, data come from a call to your function/method.
data = """<?xml version="1.0" encoding="UTF-8" ?>
<root xmlns:ns="uri">
<leaf id="1" active="on" />
<leaf id="2" active="on" />
<leaf id="3" active="off" />
</root>"""
# Everything starts with `assert_xml_document`
root = self.assert_xml_document(data)
# Check namespace
self.assert_xml_namespace(root, 'ns', 'uri')
# Check
self.assert_xpaths_unique_value(root, ('./leaf@id', ))
self.assert_xpath_values(root, './leaf@active', ('on', 'off'))
```
Running the tests
======
To run the unit tests for this package::
```
pip install tox
tox
```
===================
[![Build Status](https://travis-ci.org/richardasaurus/python-xmlunittest-better.png?branch=master)](https://travis-ci.org/richardasaurus/python-xmlunittest-better)
[![Downloads](https://pypip.in/d/xmlunittestbetter/badge.png)](https://crate.io/packages/xmlunittestbetter/)
This is a spork of [https://github.com/Exirel/python-xmlunittest](https://github.com/Exirel/python-xmlunittest).
With wider lxml support and Python 2.7, 3.4 & 3.4 support.
Examples
======
- Extend xmlunittest.XmlTestCase
- Write your tests, using the function or method that generate XML document
- Use xmlunittest.XmlTestCase‘s assertion methods to validate
- Keep your test readable
Example:
```
from xmlunittest import XmlTestCase
class CustomTestCase(XmlTestCase):
def test_my_custom_test(self):
# In a real case, data come from a call to your function/method.
data = """<?xml version="1.0" encoding="UTF-8" ?>
<root xmlns:ns="uri">
<leaf id="1" active="on" />
<leaf id="2" active="on" />
<leaf id="3" active="off" />
</root>"""
# Everything starts with `assert_xml_document`
root = self.assert_xml_document(data)
# Check namespace
self.assert_xml_namespace(root, 'ns', 'uri')
# Check
self.assert_xpaths_unique_value(root, ('./leaf@id', ))
self.assert_xpath_values(root, './leaf@active', ('on', 'off'))
```
Running the tests
======
To run the unit tests for this package::
```
pip install tox
tox
```
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
xmlunittestbetter-0.1.tar.gz
(4.9 kB
view details)
File details
Details for the file xmlunittestbetter-0.1.tar.gz
.
File metadata
- Download URL: xmlunittestbetter-0.1.tar.gz
- Upload date:
- Size: 4.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3916cc01afd6a32eb8d785fad20e7f0075e0302299f3006c668eb812bd0ff0ab |
|
MD5 | e1bd3fed5ec9a4a1fd8707db49280df9 |
|
BLAKE2b-256 | b17851d64624bc86aca0131614969b7a83487e08c22669ad070b2249ecba0cf5 |