New submission from Marius Gedminas:

unittest.signals._InterruptHandler is very nice: on first ^C it tells any 
registered unittest Result instances to gracefully stop the test run, and on 
any subsequent ^C it defers to the default interrupt handler, which immediately 
terminates the test run (possibly without giving it a chance to output summary 
information).

This doesn't work very well when a test runner forgets to register the Result 
instance: the first ^C is then quietly ignored.  (See 
https://github.com/django-nose/django-nose/issues/252 for an example.)

Suggestion: if there are no registered results in the unittest.signals._results 
dict, don't silently ignore the first ^C.  Instead, immediately defer to the 
saved interrupt handler.

Since code is often clearer than words, I'm attaching a patch.

----------
components: Library (Lib)
files: dont-ignore-first-ctrl-c.patch
keywords: patch
messages: 256656
nosy: mgedmin
priority: normal
severity: normal
status: open
title: unittest ignores the first ctrl-c when it shouldn't
type: behavior
Added file: http://bugs.python.org/file41345/dont-ignore-first-ctrl-c.patch

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue25900>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to