Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python Unittest does not return results object when the test is skipped #85786

Closed
Tabrizian mannequin opened this issue Aug 23, 2020 · 9 comments
Closed

Python Unittest does not return results object when the test is skipped #85786

Tabrizian mannequin opened this issue Aug 23, 2020 · 9 comments
Labels
3.9 only security fixes 3.10 only security fixes 3.11 only security fixes easy stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@Tabrizian
Copy link
Mannequin

Tabrizian mannequin commented Aug 23, 2020

BPO 41620
Nosy @terryjreedy, @rbtcollins, @ezio-melotti, @voidspace, @ambv, @serhiy-storchaka, @miss-islington, @iritkatriel, @Tabrizian
PRs
  • bpo-41620: Return the result when the test is being skipped #21944
  • bpo-41620: TestCase.run() now always return a TestResult instance #28030
  • [3.10] bpo-41620: TestCase.run() now always return a TestResult instance (GH-28030) #28064
  • [3.9] bpo-41620: TestCase.run() now always return a TestResult instance (GH-28030) #28065
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2021-08-30.13:44:34.182>
    created_at = <Date 2020-08-23.17:50:44.086>
    labels = ['easy', 'type-bug', '3.9', '3.10', '3.11', 'library']
    title = 'Python Unittest does not return results object when the test is skipped'
    updated_at = <Date 2021-08-30.13:44:34.182>
    user = 'https://github.com/Tabrizian'

    bugs.python.org fields:

    activity = <Date 2021-08-30.13:44:34.182>
    actor = 'lukasz.langa'
    assignee = 'none'
    closed = True
    closed_date = <Date 2021-08-30.13:44:34.182>
    closer = 'lukasz.langa'
    components = ['Library (Lib)']
    creation = <Date 2020-08-23.17:50:44.086>
    creator = 'Tabrizian'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 41620
    keywords = ['patch', 'easy']
    message_count = 9.0
    messages = ['375820', '376074', '393760', '393769', '400061', '400595', '400602', '400603', '400604']
    nosy_count = 9.0
    nosy_names = ['terry.reedy', 'rbcollins', 'ezio.melotti', 'michael.foord', 'lukasz.langa', 'serhiy.storchaka', 'miss-islington', 'iritkatriel', 'Tabrizian']
    pr_nums = ['21944', '28030', '28064', '28065']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue41620'
    versions = ['Python 3.9', 'Python 3.10', 'Python 3.11']

    @Tabrizian
    Copy link
    Mannequin Author

    Tabrizian mannequin commented Aug 23, 2020

    Result object is null when a test case is skipeed.

    @Tabrizian Tabrizian mannequin added 3.9 only security fixes labels Aug 23, 2020
    @terryjreedy
    Copy link
    Member

    You should justify the proposed change here on the issue, and see if the doc says anything about the issue either way.

    @iritkatriel iritkatriel added easy 3.11 only security fixes and removed 3.9 only security fixes labels May 12, 2021
    @iritkatriel
    Copy link
    Member

    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.

    @Tabrizian
    Copy link
    Mannequin Author

    Tabrizian mannequin commented May 16, 2021

    I'll add a documentation and unit test and update the PR.

    @serhiy-storchaka
    Copy link
    Member

    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() (bpo-44955).

    Iman, please add tests and a NEWS entry. You can use tests added in bpo-44955 as an example.

    @serhiy-storchaka serhiy-storchaka added stdlib Python modules in the Lib dir 3.9 only security fixes 3.10 only security fixes type-bug An unexpected behavior, bug, or error labels Aug 22, 2021
    @ambv
    Copy link
    Contributor

    ambv commented Aug 30, 2021

    New changeset 7e246a3 by Serhiy Storchaka in branch 'main':
    bpo-41620: TestCase.run() now always return a TestResult instance (GH-28030)
    7e246a3

    @ambv
    Copy link
    Contributor

    ambv commented Aug 30, 2021

    New changeset 0c5e0aa by Miss Islington (bot) in branch '3.9':
    bpo-41620: TestCase.run() now always return a TestResult instance (GH-28030) (GH-28065)
    0c5e0aa

    @miss-islington
    Copy link
    Contributor

    New changeset 243b8de by Miss Islington (bot) in branch '3.10':
    bpo-41620: TestCase.run() now always return a TestResult instance (GH-28030)
    243b8de

    @ambv
    Copy link
    Contributor

    ambv commented Aug 30, 2021

    Thanks for the report and initial patch, Iman! ✨ 🍰 ✨

    And thanks Serhiy for pushing this across the finish line.

    @ambv ambv closed this as completed Aug 30, 2021
    @ambv ambv closed this as completed Aug 30, 2021
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.9 only security fixes 3.10 only security fixes 3.11 only security fixes easy stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    5 participants