[New-bugs-announce] [issue25900] unittest ignores the first ctrl-c when it shouldn't

Marius Gedminas report at bugs.python.org
Fri Dec 18 03:48:29 EST 2015


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 <report at bugs.python.org>
<http://bugs.python.org/issue25900>
_______________________________________


More information about the New-bugs-announce mailing list