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 suite 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):
        self.fail_if(add_one(3) != 4, "Wrong return value")

    def test_add_two(self):
        self.fail_if(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

A test runner is included that runs 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.

Pylint Documentation Status Total downloads Downloads per month

Created and owned by Danny van der Pol, 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.10.0.tar.gz (20.1 kB view details)

Uploaded Source

Built Distribution

lily_unit_test-1.10.0-py3-none-any.whl (28.0 kB view details)

Uploaded Python 3

File details

Details for the file lily_unit_test-1.10.0.tar.gz.

File metadata

  • Download URL: lily_unit_test-1.10.0.tar.gz
  • Upload date:
  • Size: 20.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.11

File hashes

Hashes for lily_unit_test-1.10.0.tar.gz
Algorithm Hash digest
SHA256 192f50897d7e8508918ec62b779f8bb0a9012ad05ff459a968ce42196c6603d1
MD5 c1e24bc2b6c4347bcb58ac803e036d44
BLAKE2b-256 07980b7605949db98124dc24b6bbc73292b96a8a450fa71253585e07ec1d34bc

See more details on using hashes here.

File details

Details for the file lily_unit_test-1.10.0-py3-none-any.whl.

File metadata

File hashes

Hashes for lily_unit_test-1.10.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b78cda74423ebea66fc358abb5db06a3408696d48c6b3660c3715886e3abb448
MD5 e22b81382d810607c00cc8468ebfcb18
BLAKE2b-256 7084a94308a683d309c7c804ac5380cec1b702f393f2f27cf0695f5ac982a28c

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