How to suppress exception printing to console?

Qi no at no.com
Thu May 31 09:45:37 EDT 2012


On 2012-5-31 21:31, Steven D'Aprano wrote:
>> The problem is, some unit tests trigger exception on intention.
>
> I'm sorry, I don't understand what you mean by "on intention".

I mean the exception is expected.
The test will only pass if the embedded Python code raise
certain exception.

> Are you using the Python unittest module, or C++ unit tests?
>
> Python's unittest catches and suppresses exceptions, so it should not be
> printing exceptions except as part of the normal unittest output.

I use a C++ unit test framework.


>> My question is, is there any way to disable exception reporting to
>> console from either C++ or Python code?
>
> If your unit tests are raising exceptions, your tests are broken. They
> should either raise expected exceptions, in which case the exception is a
> passing test, or they are failing tests, or they are bugs in your test
> code. Fix the failing tests and the bugs in the test code, don't hide
> them.

No, I'm not hiding the exception.
I'm trying to hide the exception report text because it's not
necessary since the exception is expected.


-- 
WQ



More information about the Python-list mailing list