[TIP] unit2 fails when code in testing calls sys.exit()
jorge.vargas at gmail.com
Thu Aug 12 10:14:10 PDT 2010
On Wed, Aug 11, 2010 at 7:37 PM, Michael Foord
<fuzzyman at voidspace.org.uk> wrote:
> On 11/08/2010 21:21, Jorge Vargas wrote:
>> I think I have discovered a bug if the code you are testing calls
>> sys.exit() mainly because it discovered an unrecoverable error,
>> currently the unit2 --discover (for non-tip users) fails and just
>> exits. I have reported this at
>> http://code.google.com/p/unittest-ext/issues/detail?id=28 and proposed
>> a solution.
> Hmm.... unittest(2) could catch BaseException instead of Exception. I would
> have to special-case KeyBoardInterrupt (and OutOfMemory?) but at least
> SystemExit would be caught like any other exception during a test run.
Based on the chart at
may also cause problems with generators.
IMO it seems like a better solution to just catch Exception and
SystemExit and execute the same handling for both ? As I think all the
other subclasses of BaseException need to be handled in the code
Also remember that in py2.5 and py2.6 the hierarchy changed a little
which probably means It will be more complicated to backport.
More information about the testing-in-python