Reputation: 43456
I'm using Python's unittest
module for unit testing.
I'd like to be able to report informational messages as part of the unit test output—other than pass/fail status. Specifically in my case, I want to report whether the module under test is using the pure Python implementation or the C extension.
Is there a mechanism in unittest
to output informational messages as part of the test report? Can it be done in alternative Python unit test frameworks?
Upvotes: 2
Views: 166
Reputation: 180
I wasn't aware of nosetests and it might make sense to use that plugin for a variety of reasons. I would use the logging module myself.
Upvotes: 1
Reputation: 49216
Yes, you can use nosetests, which has a plugin system which allows this. For example the TestResult api allows to provide extended reporting:
Provides a TextTestResult that extends unittest’s _TextTestResult to provide support for error classes (such as the builtin skip and deprecated classes), and hooks for plugins to take over or extend reporting.
Upvotes: 3