Skip to main content

Python Unit Test package by LilyTronics

Project description

This package aims to be a full alternative to the Python’s build in unittest package. This package has the following features:

  • Test suite class with various build-in functions.

  • Test runner that scans all Python files in your project for test suites and executes them.

  • Single page HTML report: test report latest release.

  • Text log file of every test suit that was executed.

The package is available on PyPi.

Installation

Install the package from PyPi:

pip install lily-unit-test

Usage

The following example shows a basic test suite for your python code:

# Import the package
import lily_unit_test

# Some functions that needs testing

def add_one(x):
    return x + 1

def add_two(x):
    return x + 2


# Simply make a sub class of the lily unit test test suite
class MyTestSuite(lily_unit_test.TestSuite):

    def test_add_one(self):
        assert add_one(3) == 4, "Wrong return value"

    def test_add_two(self):
        assert add_two(3) == 5, "Wrong return value"


if __name__ == "__main__":

    # Run the test suite
    MyTestSuite().run()

Run the Python file, the output should look like this:

2023-12-20 19:28:46.105 | INFO   | Run test suite: MyTestSuite
2023-12-20 19:28:46.105 | INFO   | Run test case: MyTestSuite.test_add_one
2023-12-20 19:28:46.106 | INFO   | Test case MyTestSuite.test_add_one: PASSED
2023-12-20 19:28:46.106 | INFO   | Run test case: MyTestSuite.test_add_two
2023-12-20 19:28:46.106 | INFO   | Test case MyTestSuite.test_add_two: PASSED
2023-12-20 19:28:46.106 | INFO   | Test suite MyTestSuite: 2 of 2 test cases passed (100.0%)
2023-12-20 19:28:46.106 | INFO   | Test suite MyTestSuite: PASSED

Run the test runner to run all test suites in a folder:

from lily_unit_test import TestRunner

TestRunner.run("path/to/test_suites")

The test runner scans the folder recursively for Python files containing a test suite class.

More detailed information can be found in the documentation on Read the Docs.
The source code is available on GitHub.

Documentation Status

Created and owned by LilyTronics

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

lily-unit-test-1.9.0.tar.gz (17.6 kB view hashes)

Uploaded Source

Built Distribution

lily_unit_test-1.9.0-py3-none-any.whl (25.1 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