[Python-Dev] unittest.main() --catch parameter

Michael Foord fuzzyman at voidspace.org.uk
Thu Mar 3 22:58:21 CET 2011


On 03/03/2011 21:54, anatoly techtonik wrote:
> On Thu, Mar 3, 2011 at 10:44 PM, Michael Foord
> <fuzzyman at voidspace.org.uk>  wrote:
>> On 03/03/2011 20:31, anatoly techtonik wrote:
>>> I am looking at --help of test runner and asking the question: what is
>>> the use case for -c, --catch option?
>> It catches keyboard interrupt and instead of just bombing out of the test
>> run it reports all the results collected so far.
>>
>> Without this option interrupting a test run with a ctrl-c kills the run and
>> reports nothing. Seeing an unexpected failure or error during a long test
>> run and having to wait to the end of the test run to see the traceback can
>> be annoying, this feature solves that problem.
> Why not just leave this behavior by default and just return -1 if the
> Ctrl-C was pressed?
>

Because it means installing a signal handler which is not necessarily 
appropriate for all test systems. We *could* make it the default in the 
future (for the test runner only - not when unittest is used via the api).

>>> It doesn't look like it should be
>>> present in generic runner. I also can't find reasons to waste short
>>> option for it.
>> Nose, django and other test runners provide this option, so it is
>> functionality that people seem to value.
>>
>>> There will be big problems with people complaining
>>> about BC break even if this option is not used by anyone.
>>>
>> I don't understand this sentence, sorry.
> If the option is useless, people won't allow to remove it, because it
> will break "backward compatibility" (BC), even if they don't use this
> option themselves.

So you want it on by default but are also worried about the backwards 
compatibility issues of it even existing as an option? Anyway, your 
assertion that the option is or may be useless is unfounded. Don't worry 
about it.

All the best,

Michael Foord

>> All the best,
>>
>> Michael Foord
>>> Usage: tests.py [options] [test] [...]
>>>
>>> Options:
>>>    -h, --help       Show this message
>>>    -v, --verbose    Verbose output
>>>    -q, --quiet      Minimal output
>>>    -f, --failfast   Stop on first failure
>>>    -c, --catch      Catch control-C and display results
>>>    -b, --buffer     Buffer stdout and stderr during test runs
>>>
>>>
>>> --
>>> anatoly t.
>>> _______________________________________________
>>> Python-Dev mailing list
>>> Python-Dev at python.org
>>> http://mail.python.org/mailman/listinfo/python-dev
>>> Unsubscribe:
>>> http://mail.python.org/mailman/options/python-dev/fuzzyman%40voidspace.org.uk
>>
>> --
>> http://www.voidspace.org.uk/
>>
>> May you do good and not evil
>> May you find forgiveness for yourself and forgive others
>> May you share freely, never taking more than you give.
>> -- the sqlite blessing http://www.sqlite.org/different.html
>>
>>


-- 
http://www.voidspace.org.uk/

May you do good and not evil
May you find forgiveness for yourself and forgive others
May you share freely, never taking more than you give.
-- the sqlite blessing http://www.sqlite.org/different.html



More information about the Python-Dev mailing list