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.
Created and owned by LilyTronics
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for lily_unit_test-1.9.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c21c2906004d54ac2015ce5c0d35ba1067a0bdf78f14b52027d3dd899f541564 |
|
MD5 | 0a3a372caa8d6dc60654cf3096e6bb63 |
|
BLAKE2b-256 | 41ff3916484dc8ea93cd34553db5b5e1f352d0aa6fac07a4c6b2227b17d43745 |