[New-bugs-announce] [issue41322] unittest: Generator test methods will always be marked as passed

Alexander Hungenberg report at bugs.python.org
Fri Jul 17 05:46:57 EDT 2020


New submission from Alexander Hungenberg <alexander.hungenberg at gmail.com>:

The following testcase will always be marked as passed:

from unittest import TestCase

class BuggyTestCase(TestCase):
    def test_generator(self):
        self.assertTrue(False)
        yield None


It happened to us that someone accidentally made the test method a generator function. That error was caught very late, because it always appears to have executed correctly.

Maybe an additional check can be introduced in the unittest module, to check if a test_ method was executed correctly?

----------
components: Library (Lib)
messages: 373807
nosy: defreng
priority: normal
severity: normal
status: open
title: unittest: Generator test methods will always be marked as passed
type: behavior
versions: Python 3.8

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue41322>
_______________________________________


More information about the New-bugs-announce mailing list