Skip to main content

A testing utility package

Project description

Project Title

A lightweight decorator based testing package for Python 3.5+.

Installing

The easiest way to install is to use pip:

pip install zest

or

python3 -m pip install zest

You can also download the source and place it the directory of the module you want to use it in. An example directory structure is shown below:

  • project_directory
    • zest
      • zest's files here
    • your_file.py
    • your_test_file.py

Getting Started

A suggested workflow is to write the test first in a seperate tests.py file, like so:

from zest import tests, raises, test_all
import main

@tests(main.squared)
def test_squared(func = None):
    """Ensure squaring is done accureately and only squarable types are squared"""
    # Make sure ValueError is thrown if invalid imputs are given
    assert raises(TypeError, func, "NaN"), "Should raise TypeError when 'NaN' supplied"

    assert raises(TypeError, func, {1, 2, 3}), "Should raise TypeError when {1, 2, 3} supplied"

    assert func(4) == 16, "4^2 is 16, received %s" % func(4)
    assert func(5) == 25, "5^2 is 25, received %s" % func(5)

print(test_squared())

Note multiple tests can be placed in one test function. main.py simply contains a function called squared that squares the input and returns it.

Zest keeps track of all registered testing functions, allowing you to run them all at once, and get grouped information on the results of the test, like so:

print(test_all())

At the moment test_all() only returns a pretty print output, but in the future this will be fleshed out to be more comprehensive

Prerequisites

Python 3.5+

Authors

Jeremy Zolnai-Lucas - Initial work - Jezza672

License

This project is licensed under the MIT License - see the LICENSE file for details

Project details


Download files

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

Files for zest, version 0.1.1.post1
Filename, size File type Python version Upload date Hashes
Filename, size zest-0.1.1.post1-py3-none-any.whl (3.6 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size zest-0.1.1.post1.tar.gz (3.0 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page