classification
Title: Python Unittest does not return results object when the test is skipped
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.11, Python 3.10, Python 3.9
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: Tabrizian, ezio.melotti, iritkatriel, lukasz.langa, michael.foord, miss-islington, rbcollins, serhiy.storchaka, terry.reedy
Priority: normal Keywords: easy, patch

Created on 2020-08-23 17:50 by Tabrizian, last changed 2021-08-30 13:44 by lukasz.langa. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 21944 closed Tabrizian, 2020-08-23 17:50
PR 28030 merged serhiy.storchaka, 2021-08-29 12:01
PR 28064 merged miss-islington, 2021-08-30 13:16
PR 28065 merged miss-islington, 2021-08-30 13:16
Messages (9)
msg375820 - (view) Author: Iman Tabrizian (Tabrizian) * Date: 2020-08-23 17:50
Result object is null when a test case is skipeed.
msg376074 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2020-08-29 20:02
You should justify the proposed change here on the issue, and see if the doc says anything about the issue either way.
msg393760 - (view) Author: Irit Katriel (iritkatriel) * (Python committer) Date: 2021-05-16 21:10
I agree with Iman that this looks like a bug because the code updates the result object with skip info but then doesn't return it.

The patch needs a unit test covering this, as well as probably a doc update.
msg393769 - (view) Author: Iman Tabrizian (Tabrizian) * Date: 2021-05-16 23:37
I'll add a documentation and unit test and update the PR.
msg400061 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2021-08-22 09:05
It is a bug because there is a difference between the following cases:

    @skip("skipped")
    def test1(self):
        ...

    @other_decorator
    @skip("skipped")
    def test2(self):
        ...

    def test2(self):
        self.skipTest("skipped")
        ...

None is only returned in the first case. In other two cases a TestResult is returned with information about skipping.

It is obvious that it was unintentionally.

I just have fixed similar bug about calling stopTestRun() (issue44955).

Iman, please add tests and a NEWS entry. You can use tests added in issue44955 as an example.
msg400595 - (view) Author: Łukasz Langa (lukasz.langa) * (Python committer) Date: 2021-08-30 13:16
New changeset 7e246a3a7b43762480ee4fe0cfb859e8e997a8c8 by Serhiy Storchaka in branch 'main':
bpo-41620: TestCase.run() now always return a TestResult instance (GH-28030)
https://github.com/python/cpython/commit/7e246a3a7b43762480ee4fe0cfb859e8e997a8c8
msg400602 - (view) Author: Łukasz Langa (lukasz.langa) * (Python committer) Date: 2021-08-30 13:42
New changeset 0c5e0aa73f6f70d16d21ad9e1eb2d0fe3a334f0a by Miss Islington (bot) in branch '3.9':
bpo-41620: TestCase.run() now always return a TestResult instance (GH-28030) (GH-28065)
https://github.com/python/cpython/commit/0c5e0aa73f6f70d16d21ad9e1eb2d0fe3a334f0a
msg400603 - (view) Author: miss-islington (miss-islington) Date: 2021-08-30 13:43
New changeset 243b8de0b15061704581974c0a27db1232a43b93 by Miss Islington (bot) in branch '3.10':
bpo-41620: TestCase.run() now always return a TestResult instance (GH-28030)
https://github.com/python/cpython/commit/243b8de0b15061704581974c0a27db1232a43b93
msg400604 - (view) Author: Łukasz Langa (lukasz.langa) * (Python committer) Date: 2021-08-30 13:44
Thanks for the report and initial patch, Iman! ✨ 🍰 ✨  

And thanks Serhiy for pushing this across the finish line.
History
Date User Action Args
2021-08-30 13:44:34lukasz.langasetstatus: open -> closed
resolution: fixed
messages: + msg400604

stage: patch review -> resolved
2021-08-30 13:43:42miss-islingtonsetmessages: + msg400603
2021-08-30 13:42:41lukasz.langasetmessages: + msg400602
2021-08-30 13:16:37miss-islingtonsetpull_requests: + pull_request26509
2021-08-30 13:16:33miss-islingtonsetnosy: + miss-islington
pull_requests: + pull_request26508
2021-08-30 13:16:33lukasz.langasetnosy: + lukasz.langa
messages: + msg400595
2021-08-29 21:11:23serhiy.storchakalinkissue36674 dependencies
2021-08-29 12:01:19serhiy.storchakasetkeywords: + patch
stage: test needed -> patch review
pull_requests: + pull_request26475
2021-08-22 09:05:47serhiy.storchakasettype: behavior
components: + Library (Lib)
versions: + Python 3.9, Python 3.10
nosy: + serhiy.storchaka

messages: + msg400061
stage: test needed
2021-05-16 23:37:08Tabriziansetmessages: + msg393769
2021-05-16 21:10:11iritkatrielsetmessages: + msg393760
2021-05-16 21:08:58iritkatrielsetmessages: - msg393489
2021-05-16 21:08:49iritkatrielsetmessages: - msg384971
2021-05-12 09:07:55iritkatrielsetversions: + Python 3.11, - Python 3.9
2021-05-12 09:07:49iritkatrielsetkeywords: + easy

messages: + msg393489
2021-01-12 18:10:46iritkatrielsetnosy: + iritkatriel
messages: + msg384971
2020-08-29 20:02:16terry.reedysetnosy: + ezio.melotti, terry.reedy, michael.foord, rbcollins
messages: + msg376074
2020-08-23 17:50:44Tabriziancreate