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.
Install the package from PyPi:
pip install lily-unit-test
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.
Created and owned by Danny van der Pol, LilyTronics