A more readable text output for Python's built in unittest framework
Project description
Better PyUnit Format
A more readable text output for Python's built in unittest framework
Overview
This package provides an implementation of a test runner and a test result for the Python unittest package.
This package simply creates an override of the built-in TextTestRunner that removes all the formatting that it does by default and only runs the test suite. This means that this test runner passes all formatting responsibility on to the test result.
The test result that this package provides formats the output of the test in a much more readable way to make interpreting unit test results a bit easier for introductory students.
This package is targeted towards students and education and was built with that limited use case in mind. With that said, please, feel free to use this in your applications and tell me what you think!
Using Better PyUnit Format
- Install the package via pip with
pip install Better-PyUnit-Format
- Import the
BetterPyUnitTestRunner
- Run your testsuite!
Example code
# run.py
import unittest
import test
from BetterPyUnitFormat import BetterPyUnitTestRunner
if __name__ == "__main__":
testSuite = unittest.loader.makeSuite(test.Test)
runner = BetterPyUnitTestRunner()
runner.run(testSuite)
Example Execution
# test.py
import unittest
class Test(unittest.TestCase):
def test_failure(self):
"""This test should fail"""
self.assertEquals(1, 2)
def test_success(self):
"""This test should pass"""
self.assertEquals(1, 1)
def test_error(self):
"""This test will error"""
0/0
@unittest.skip("Skipping this test :)")
def test_skip(self):
"""This test will be skipped"""
self.assertEquals(1, 2)
====================
--------------------
[ RUN ] This test will error (test.Test.test_error)
[ ERROR ] This test will error
A(n) ZeroDivisionError occurred:
[ZeroDivisionError] division by zero
--------------------
--------------------
[ RUN ] This test should fail (test.Test.test_failure)
[ FAIL ] This test should fail
Failure reason:
1 != 2
--------------------
--------------------
[ RUN ] This test will be skipped (test.Test.test_skip)
[ SKIP ] This test will be skipped
Skip Reason: Skipping this test :)
--------------------
--------------------
[ RUN ] This test should pass (test.Test.test_success)
[ OK ] This test should pass
--------------------
====================
[ FAILED ]
1 tests passed.
1 tests failed.
1 tests errored.
1 tests skipped.
1 / 4
====================
License
This package is licensed under the Unlicense. Feel free to use it for any purpose commercial or non-commercial.
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
Built Distribution
File details
Details for the file better_pyunit_format-0.2.2.tar.gz
.
File metadata
- Download URL: better_pyunit_format-0.2.2.tar.gz
- Upload date:
- Size: 4.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1b3cfc0bfd4df0710f0403b1132614cb6f52c86464464def7b7810be2bc083c3 |
|
MD5 | 96afd17b3691e12260df65d315df2b5b |
|
BLAKE2b-256 | a1b955a0d1744f67f861af3c3cb2ae4b9b8be9bea393e82cf1979587c77692c3 |
File details
Details for the file Better_PyUnit_Format-0.2.2-py3-none-any.whl
.
File metadata
- Download URL: Better_PyUnit_Format-0.2.2-py3-none-any.whl
- Upload date:
- Size: 5.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4ae8128ade1af2d3227e2ef8940ac50ef3b509a58e07190669ee574595422287 |
|
MD5 | 372f11aabe7f8e32d0525679fb52f2db |
|
BLAKE2b-256 | ef6b2ea64609877948b02562dda84122134504951fe718a41de5a233ace25ed7 |