colour-runner
colour-runner is a Python library designed to provide color formatting for standard `unittest` test output. The project's last release was 0.1.1 in October 2018, and it has seen no significant updates since then. It is considered abandoned due to lack of maintenance, making it potentially incompatible with newer Python versions and modern testing practices.
Common errors
-
ModuleNotFoundError: No module named 'colour_runner.runner'
cause Incorrect import path for `ColourTextTestRunner`.fixEnsure you are importing from the correct submodule: `from colour_runner.runner import ColourTextTestRunner`. -
TypeError: __init__() got an unexpected keyword argument 'stream'
cause This error might occur when `ColourTextTestRunner` is instantiated with arguments that are no longer compatible with `unittest.TextTestRunner` in newer Python versions due to API changes in `unittest`.fixDowngrade to a Python version compatible with the library (e.g., Python 3.5 or earlier, as indicated by PyPI classifiers), or switch to a different test runner. Debugging the `unittest` source for the specific Python version might reveal the exact API change.
Warnings
- breaking The `colour-runner` library is unmaintained since 2018 and has not been tested with recent Python versions (3.6+). It may exhibit unexpected behavior or fail to run on modern Python environments due to API changes or dependency updates in the standard library.
- gotcha As an alpha-stage project (Development Status :: 3 - Alpha), `colour-runner` was never intended for stable production use. Its APIs might not be fully robust or well-documented.
- gotcha Terminal color output can be inconsistent across different operating systems, terminal emulators, and Python environments. An older library like `colour-runner` may not correctly detect or output ANSI escape codes for all modern setups, leading to plain text output or corrupted terminal displays.
Install
-
pip install colour-runner
Imports
- ColourTextTestRunner
from colour_runner import ColourTextTestRunner
from colour_runner.runner import ColourTextTestRunner
- ColourTextTestResult
from colour_runner import ColourTextTestResult
from colour_runner.result import ColourTextTestResult
- ColourRunnerMixin (for Django)
from colour_runner.runner import ColourRunnerMixin
from colour_runner.django_runner import ColourRunnerMixin
Quickstart
import unittest
from colour_runner.runner import ColourTextTestRunner
class ExampleTests(unittest.TestCase):
def test_success(self):
self.assertTrue(True)
def test_failure(self):
self.fail("This test is designed to fail")
@unittest.skip("demonstrating skipping a test")
def test_skipped(self):
self.fail("This test should not run")
if __name__ == '__main__':
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(ExampleTests))
runner = ColourTextTestRunner(verbosity=2)
print("\nRunning tests with colour-runner:\n")
runner.run(suite)