mock.patch.object does not persist __module__ name for functions

Open
#81,015 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Stale
Tech stack
python
Domain
testing-qa

Research direction

Start with the minimal-test-case.zip attachment and the mock.patch.object behavior described in the issue. Review the relevant library code and tests under the reported Library (Lib) and Tests components, then run the minimal case. Done means functions patched with mock.patch.object retain their module name.

Written by the indexing model from the issue text.

Description

3.7 (EOL) 3.8 (EOL) stdlib tests type-bug
BPO 36834
Nosy @cjw296, @voidspace, @mariocj89, @goodspark, @tirkarthi
Files
  • minimal-test-case.zip: ZIP file with minimal test case
  • 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 = None
    created_at = <Date 2019-05-07.14:44:21.027>
    labels = ['3.7', 'tests', '3.8', 'type-bug', 'library']
    title = 'mock.patch.object does not persist __module__ name for functions'
    updated_at = <Date 2019-05-07.15:46:44.614>
    user = 'https://github.com/goodspark'
    

    bugs.python.org fields:

    activity = <Date 2019-05-07.15:46:44.614>
    actor = 'xtreak'
    assignee = 'none'
    closed = False
    closed_date = None
    closer = None
    components = ['Library (Lib)', 'Tests']
    creation = <Date 2019-05-07.14:44:21.027>
    creator = 'spark'
    dependencies = []
    files = ['48309']
    hgrepos = []
    issue_num = 36834
    keywords = []
    message_count = 2.0
    messages = ['341738', '341756']
    nosy_count = 5.0
    nosy_names = ['cjw296', 'michael.foord', 'mariocj89', 'spark', 'xtreak']
    pr_nums = []
    priority = 'normal'
    resolution = None
    stage = None
    status = 'open'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue36834'
    versions = ['Python 3.7', 'Python 3.8']
    

    Dominant language
    Python
    Stars
    77.2k
    Forks
    36k
    Avg merge
    1d 9h
    Merged PRs (30d)
    558

    Contributor guide

    Open the contributing guide

    First steps

    1. Read the whole issue, then the project's contributing guide.
    2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
    3. Fork the repository and make your change on a branch.
    4. Open a pull request that references the issue number.

    More from python/cpython

    All issues in python/cpython

    Similar issues

    More Python issues

    Get new issues in your inbox

    A short digest of beginner-friendly GitHub issues.