Skip to main content

Touca SDK for Python

Project description

Touca Python SDK

PyPI License PyPI - Python Version Build Status Documentation Status Code Coverage

Install

pip install touca

We support Python v3.7 and newer.

Sneak Peak

For a more thorough guide of how to use Touca SDK for Python, refer to our documentation website.

Let us imagine that we want to test a software workflow that takes the username of a student and provides basic information about them.

def test_find_student():
    alice = find_student("alice")
    assert alice.fullname == "Alice Anderson"
    assert alice.dob == date(2006, 3, 1)
    assert alice.gpa == 3.9

We can use unit testing in which we hard-code expected values for each input. But real-world software is complex:

  • We need a large number of test inputs to gain confidence that our software works as expected.
  • Describing the expected behavior of our software for each test input is difficult.
  • When we make intentional changes to the behavior of our software, updating our expected values is cumbersome.

Touca is effective in testing software workflows that need to handle a large variety of inputs or whose expected behavior is difficult to hard-code.

import touca
from students import find_student

@touca.workflow(testcases=["alice", "bob", "charlie"])
def students_test(username: str):
    student = find_student(username)
    touca.check("fullname", student.fullname)
    touca.check("dob", student.dob)
    touca.check("gpa", student.gpa)

This is slightly different from a typical unit test:

  • Touca tests do not use expected values.
  • Touca tests do not hard-code input values.

With Touca, we describe how we run our code under test for any given test case. We can capture values of interesting variables and runtime of important functions to describe the behavior and performance of our workflow for that test case.

Sample Test Output

Now if we make changes to our workflow under test, we can rerun this test and let Touca automatically compare our captured data points against those of a previous baseline version and report any difference in behavior or performance.

Documentation

  • Documentation Website: If you are new to Touca, this is the best place to start.
  • Python SDK API Reference: Auto-generated source code documentation for Touca Python SDK with explanation about individual API functions.
  • Python Examples: Sample Python projects that show how to use Touca in various real-world use-cases.

Community

We hang on Discord. Come say hi! We love making new friends. If you need help, have any questions, or like to contribute or provide feedback, that's the best place to be.

Contributing

We welcome all forms of contributions, from adding new features to improving documentation and sharing feedback.

FAQ

  • Should I install Touca as a development dependency?

    Yes, unless you like to capture data-points that are not accessible through your software's public API. Touca data capturing functions (e.g. touca.check and touca.scoped_timer) are no-op in production environments. They only work when called from a @touca.workflow context.

  • How is Touca making money?

    Touca is open-source software that you can self-host for free. Touca, Inc. operates Touca Cloud: a managed cloud instance of Touca with additional enterprise-ready features. We have a free plan and leverage usage-based pricing to charge for storage and service. Visit our pricing page to learn more.

License

This repository is released under the Apache-2.0 License. See LICENSE.

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

touca-1.8.7.tar.gz (44.1 kB view details)

Uploaded Source

Built Distribution

touca-1.8.7-py3-none-any.whl (58.4 kB view details)

Uploaded Python 3

File details

Details for the file touca-1.8.7.tar.gz.

File metadata

  • Download URL: touca-1.8.7.tar.gz
  • Upload date:
  • Size: 44.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.2 CPython/3.10.10 Linux/5.15.0-1033-azure

File hashes

Hashes for touca-1.8.7.tar.gz
Algorithm Hash digest
SHA256 244a52be4cf4670077fda0b740ac067470745da7084c241bc619b332f771d940
MD5 5861d79048a30a01762d14cae9e3222e
BLAKE2b-256 c86de1986d8c9b4f6cd2b583d0df8bd1769989b5ce5cb91dcc613b0d187e4a7a

See more details on using hashes here.

File details

Details for the file touca-1.8.7-py3-none-any.whl.

File metadata

  • Download URL: touca-1.8.7-py3-none-any.whl
  • Upload date:
  • Size: 58.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.2 CPython/3.10.10 Linux/5.15.0-1033-azure

File hashes

Hashes for touca-1.8.7-py3-none-any.whl
Algorithm Hash digest
SHA256 1f1e3d811ee913d47ced31b09b83e32875c55b651f4d616803fb3b2ffb60b9b3
MD5 e2e72a8fd5847230fb0e3cdcefc64518
BLAKE2b-256 7088cdecec04888bf1f5f611c4b02e00bd702a26a095433bf3e2936b6efaa769

See more details on using hashes here.

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