Skip to main content

tavalidate, utilities to help you validate Tavern response.

Installation

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:

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

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.

extra_kwargs

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

expected

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

strict

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

array

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:

response:
  save:
    $ext:
      function: tavalidate:save_xml
      extra_kwargs:
        variables:
          bar: '/foo/bar/text()'
          at1: '/foo/@at1'

Logging

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

Metadata

Release files for tavalidate 0.0.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tavalidate 0.0.6
File Size Uploaded
tavalidate-0.0.6.tar.gz 4.6 kB Details

Release files / tavalidate-0.0.6.tar.gz

Download URL tavalidate-0.0.6.tar.gz
Size 4.6 kB
Tags Source
SHA-256 checksum
How to use checksums
bbf75c33e4edf1fdaa094f0e204c4771c5d1eaa309e37010a445e0826291cccc
BLAKE2b-256 checksum
How to use checksums
ba2746982490e224753ef68a608559616d74efe3ce49ce033422fead92dc61eb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.6

Release history Release notifications | RSS feed

This release

0.0.6 This release

1 release file

0.0.5

1 release file

0.0.3

1 release file

0.0.2

1 release file

0.0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page