Skip to main content

A testing utility package

Project description

Project Title

A lightweight decorator based testing package for Python 3.5+.

Getting Started

Whichever method you use, you will then need to import the module:

from zest import test, zest

my_function_tester(func):
    assert func(x, y)

@test(my_function_tester)
def my_function(x, y):
    return x* y

print(zest.run())

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+

### 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.

## Authors

**Jeremy Zolnai-Lucas** - *Initial work* - [Jezza672](https://github.com/Jezza672)

## License

This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) 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.

Source Distribution

zest-0.1.1.tar.gz (3.0 kB view hashes)

Uploaded Source

Built Distribution

zest-0.1.1-py3-none-any.whl (3.5 kB view hashes)

Uploaded Python 3

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