[issue41322] unittest: Generator test methods will always be marked as passed

2020-07-17 Thread Zachary Ware
Zachary Ware added the comment: In the same vein as Serhiy's suggestion, I would like to see unittest raise a DeprecationWarning when a test method returns anything other than `None`, and eventually switch that to an error (probably TypeError or ValueError). -- nosy: +zach.ware

[issue41322] unittest: Generator test methods will always be marked as passed

2020-07-17 Thread Alexander Hungenberg
Alexander Hungenberg added the comment: I would also strongly vote for raising an error if the test method is a generator - not even silently turn it into a list. It would be straight forward to implement various checks (like the ones you mentioned for generators, coroutines, ...) - and they

[issue41322] unittest: Generator test methods will always be marked as passed

2020-07-17 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: I would raser raise error if the test method returns something suspicious, like generator or coroutine. Or maybe if it returns anything except None. -- nosy: +serhiy.storchaka ___ Python tracker

[issue41322] unittest: Generator test methods will always be marked as passed

2020-07-17 Thread Karthikeyan Singaravelan
Karthikeyan Singaravelan added the comment: This is a duplicate of issue15551 and as per discussion in the thread my approach is incoherent with design of unittest to execute generators. I propose closing this as duplicate with same resolution as not fixed unless there is a change required h

[issue41322] unittest: Generator test methods will always be marked as passed

2020-07-17 Thread Karthikeyan Singaravelan
Karthikeyan Singaravelan added the comment: https://github.com/python/cpython/blob/8e836bb21ce73f0794fd769db5883c29680dfe47/Lib/unittest/case.py#L548 . _callTestMethod just calls the test method and doesn't check for the method to be a generator function to be iterated through. In Python 3.8

[issue41322] unittest: Generator test methods will always be marked as passed

2020-07-17 Thread Alexander Hungenberg
New submission from Alexander Hungenberg : 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