bpo-41620: Return the result when the test is being skipped#21944
bpo-41620: Return the result when the test is being skipped#21944Tabrizian wants to merge 1 commit intopython:mainfrom Tabrizian:patch-1
Conversation
|
Hello, and thanks for your contribution! I'm a bot set up to make sure that the project can legally accept this contribution by verifying everyone involved has signed the PSF contributor agreement (CLA). Recognized GitHub usernameWe couldn't find a bugs.python.org (b.p.o) account corresponding to the following GitHub usernames: This might be simply due to a missing "GitHub Name" entry in one's b.p.o account settings. This is necessary for legal reasons before we can look at this contribution. Please follow the steps outlined in the CPython devguide to rectify this issue. You can check yourself to see if the CLA has been received. Thanks again for the contribution, we look forward to reviewing it! |
|
Fixed the CLA and created a bug report. Also, opened an account in bugs.python.org. |
|
(1) Why is the result useful when no test was executed? |
import unittest
import json
class TestResultCollector(unittest.TestCase):
@classmethod
def setResult(cls, total, errors, failures):
cls.total, cls.errors, cls.failures = \
total, errors, failures
@classmethod
def tearDownClass(cls):
json_res = {
'total': cls.total,
'errors': cls.errors,
'failures': cls.failures
}
print(json.dumps(json_res))
def test1(self):
self.assertTrue(True)
def test2(self):
self.assertTrue(True)
def test3(self):
self.assertTrue(True)
@unittest.skip('Skip Test')
def test4(self):
self.assertTrue(True)
def run(self, result=None):
test_result = super().run(result)
total = test_result.testsRun
errors = len(test_result.errors)
failures = len(test_result.failures)
self.setResult(total, errors, failures)
if __name__ == '__main__':
unittest.main()
|
|
I think it is a valid change. Please resolve conflicts and add tests. |
|
Closing in favor of GH-28030. |
Currently unittest does not return
TestResultobject when the test is skipped.https://bugs.python.org/issue41620