Skip to main content

Utilities to help you validate and save Tavern response.

Project description

tavalidate, utilities to help you validate Tavern response.


Tavalidate can be installed through pip.

pip install tavalidate

XML Validate

Tavern has great built-in Json support, but things are difficult when it comes to XML. Use tavalidate.xmlv package to validate XML response.

XML validation example:

  status_code: 200
    function: tavalidate:assert_xml
      expected: |
        <foo attr="!anystr">
          <bar attr2="baz">!anyint</bar>

Simply put, pass the expected xml as an argument to the tavalidate.xmlv.validate function. The function will validate the xml structure, node value and attribute value.


Below are the supported extra kwargs of tavalidate.xmlv.validate function.


This is the expected XML string.

You may use some (not all) of the tavern magic values to match data of your specified type:

  • !anything: This matches value of any type.
  • !anystr: Matches any string
  • !anyint: Matches any integer
  • !anyfloat: Matches any float
  • !anybool: Matches any boolean


Use strict: True if you want to make sure there's no extra tag in the response.


Since XML do not have the concept of array. When validating an array-like element, the same number of children of the same tag must exist. Regardless whether strict mode is used or not. All element in corresponding order must match for the container to match.

XML Save

Use tavalidate.xmlv package to save XML response.

It allows you to use XPath to specify the value to save inside the xml document. If the XPath somehow selects multiple nodes, tavalidate will print a warning, but the first value will still be saved.

XML save example:

      function: tavalidate:save_xml
          bar: '/foo/bar/text()'
          at1: '/foo/@at1'


Configure the logger tavalidate so you can see the response body and other logs in DEBUG level.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tavalidate-0.0.6.tar.gz (4.6 kB view hashes)

Uploaded source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page