Skip to main content

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

Project description

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.

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

utterless-0.4.2.tar.gz (4.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

utterless-0.4.2-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

Details for the file utterless-0.4.2.tar.gz.

File metadata

  • Download URL: utterless-0.4.2.tar.gz
  • Upload date:
  • Size: 4.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.2

File hashes

Hashes for utterless-0.4.2.tar.gz
Algorithm Hash digest
SHA256 52a204413f399a40da2c8efd42dcd4acea09f189b07df3f2a585d8c42fda5df7
MD5 6816db3e761449fb59192c1cc95c891a
BLAKE2b-256 b609c7218ff3fff83915a746f4d40d66bca9e6b75ebcd4354e4833d7e7c39e43

See more details on using hashes here.

File details

Details for the file utterless-0.4.2-py3-none-any.whl.

File metadata

  • Download URL: utterless-0.4.2-py3-none-any.whl
  • Upload date:
  • Size: 5.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.2

File hashes

Hashes for utterless-0.4.2-py3-none-any.whl
Algorithm Hash digest
SHA256 c3f7679020f0d56616ca4662738a057a1c309dddd0e50d3f7a02c12a17f4addf
MD5 a4092508f6892d5d27a4c6c26ffd5079
BLAKE2b-256 79d85421d1d9cfb328bc10c9372f3ff680dfd000ffab98a70f77978aa8a2a063

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page