Skip to main content

Utterless

Extend Python's "unittest" to better handle "logging" messages

There's a problem when you try to run a unittest test suite in a codebase which also uses the logging framework: You see your nice output of dots (...F....SS....F..) clogged up with lots of log messages.

For occasional cases you can supress log messages in a block of code with self.assertLogs(...). But that doesn't scale when almost every test in your suite generates messages.

Alternatively you can fiddle your log levels so that all log messages get supressed. But when you have a failing test the log messages can be very helpful in debugging it.

Wouldn't it be great to have an alternative log runner that captures all log messages. If the test fails the messages get displayed with the error traceback. But if the test succeeds then the log messages get silently discarded.

Look no further! This is possibly the package you want.

Usage

We assume you already have a test suite that you run something like this:

$ python -m unittest discover

Having installed utterless you just need to replace that with:

$ python -m utterless discover

Optional Usage

Utterless has mechanisms to integrate with some frameworks that don't run tests through unittest directly.

For example, with Django you can specify the Utterless test runner on the command line:

$ ./manage.py test --testrunner utterless.contrib.django.DiscoverRunner

or by editing settings.py to contain:

TEST_RUNNER = "utterless.contrib.django.DiscoverRunner"

Licence

This software copyright P. S. Clarke and is licensed in accordance with the BSD Three-Clause Licence.

Limitations and Roadmap

  • Currently it completely ignores the warnings module, so output from that (e.g. a DeprecationWarning or a ResourceWarning) will still splurts across the screen. I could possibly collect that up during tests and include it at the end. The complication is that warnings should probably still be emited regardless of whether the test passed or failed. Treating warnings as errors might be the better option.

Release files for utterless 0.4.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for utterless 0.4.3
File Size Uploaded
utterless-0.4.3.tar.gz 6.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for utterless 0.4.3
File Interpreter ABI Platform
utterless-0.4.3-py3-none-any.whl Python 3 none any Details

Total release size: 11.9 kB

Release files / utterless-0.4.3.tar.gz

Download URL utterless-0.4.3.tar.gz
Size 6.3 kB
Tags Source
SHA-256 checksum
How to use checksums
d0e849749efc2ebbcf4011193802176880c473a398d8b56d4d8fbc3f43690fc7
BLAKE2b-256 checksum
How to use checksums
d118443ed18afcf0d319cf57207b11333749a99c7ccb1fd3e773775292d98952
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.5

Release files / utterless-0.4.3-py3-none-any.whl

Download URL utterless-0.4.3-py3-none-any.whl
Size 5.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
83e67c32252924052ce6e84ab6c922c20bbfb304c33df8c06542a86565dbe2d9
BLAKE2b-256 checksum
How to use checksums
a0b9f0537d49f5e27c944599583b6fe451aaa6a4fc2a4ee2053eab75d6fd1b95
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.5

Release history Release notifications | RSS feed

This release

0.4.3 This release

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page