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

reset_mock needs parameters to also reset return_value and side_effect #65470

Closed
voidspace opened this issue Apr 16, 2014 · 7 comments
Closed
Assignees
Labels
stdlib Python modules in the Lib dir type-feature A feature request or enhancement

Comments

@voidspace
Copy link
Contributor

voidspace commented Apr 16, 2014

BPO 21271
Nosy @voidspace, @PCManticore, @berkerpeksag, @kushaldas
Files
  • issue21271.patch: New parameters for reset_mock
  • issue21271v2.patch: Version 2 of the patch
  • 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 = 'https://github.com/voidspace'
    closed_at = <Date 2016-06-02.17:23:44.513>
    created_at = <Date 2014-04-16.20:51:44.316>
    labels = ['type-feature', 'library']
    title = 'reset_mock needs parameters to also reset return_value and side_effect'
    updated_at = <Date 2016-06-02.17:29:18.239>
    user = 'https://github.com/voidspace'

    bugs.python.org fields:

    activity = <Date 2016-06-02.17:29:18.239>
    actor = 'python-dev'
    assignee = 'michael.foord'
    closed = True
    closed_date = <Date 2016-06-02.17:23:44.513>
    closer = 'kushal.das'
    components = ['Library (Lib)']
    creation = <Date 2014-04-16.20:51:44.316>
    creator = 'michael.foord'
    dependencies = []
    files = ['38987', '38989']
    hgrepos = []
    issue_num = 21271
    keywords = ['patch']
    message_count = 7.0
    messages = ['216588', '240585', '240888', '240890', '240906', '266895', '266896']
    nosy_count = 5.0
    nosy_names = ['michael.foord', 'Claudiu.Popa', 'python-dev', 'berker.peksag', 'kushal.das']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue21271'
    versions = ['Python 3.5']

    @voidspace
    Copy link
    Contributor Author

    voidspace commented Apr 16, 2014

    unittest.mock.Mock.reset_mock deliberately doesn't reset the return_value and side_effect. It would be nice if it gained parameters so that it *could*.

    @voidspace voidspace added the type-bug An unexpected behavior, bug, or error label Apr 16, 2014
    @voidspace voidspace self-assigned this Apr 16, 2014
    @voidspace voidspace added the stdlib Python modules in the Lib dir label Apr 16, 2014
    @kushaldas
    Copy link
    Member

    kushaldas commented Apr 13, 2015

    Working on it. Will submit the patch tomorrow.

    @kushaldas
    Copy link
    Member

    kushaldas commented Apr 14, 2015

    A patch without NEWS and whatsnew update. I will fill them before commit.

    The reset_mock function now has two parameters, return_value, and side_effect. Passing True value to any of these will reset that attribute.

    @berkerpeksag
    Copy link
    Member

    berkerpeksag commented Apr 14, 2015

    I left a couple of comments of Rietveld.

    @berkerpeksag berkerpeksag added type-feature A feature request or enhancement and removed type-bug An unexpected behavior, bug, or error labels Apr 14, 2015
    @kushaldas
    Copy link
    Member

    kushaldas commented Apr 14, 2015

    Updated patch with the suggestions from Berker.

    @kushaldas
    Copy link
    Member

    kushaldas commented Jun 2, 2016

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Jun 2, 2016

    New changeset b110dd3d6cea by Kushal Das in branch 'default':
    Issue bpo-21271: Adds new keyword only parameters in reset_mock call
    https://hg.python.org/cpython/rev/b110dd3d6cea

    @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
    stdlib Python modules in the Lib dir type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants