Errors in code fail silently in unit tests
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
OpenStack Dashboard (Horizon) |
Confirmed
|
Low
|
Unassigned |
Bug Description
Looking at a recent review (https:/
https:/
When commenting the try:except block, the unit test failed, and here is the fix that was needed to bring tests back to passed:
http://
Let's see how to change unittest verbosity and make the error messages appear in unit tests result even if a test is passed. This is a must for at least LOG.exception messages.
If errors are occuring undetected in unit tests, then it is important to address this problem. But I disagree with the approach of logging all exceptions, even when the test passes; this causes false positives to appear in the unit test logs, such as those addressed by https:/ /review. openstack. org/#/c/ 115368/.
A better approach would be to provide a way for the test to specify which log messages are expected, and to suppress those, yet permit all other errors to be displayed. In other words, something akin to https:/ /docs.python. org/2/library/ unittest. html#unittest. TestCase. assertRaisesReg exp, but where the regexp matches (and suppresses) the log message rather than the text of the exception itself.
Does that sound like a reasonable alternative?