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

patch.object should raise another error when first argument is a str #82850

Closed
elenaoat mannequin opened this issue Nov 3, 2019 · 5 comments
Closed

patch.object should raise another error when first argument is a str #82850

elenaoat mannequin opened this issue Nov 3, 2019 · 5 comments
Labels
3.9 only security fixes tests Tests in the Lib/test dir type-feature A feature request or enhancement

Comments

@elenaoat
Copy link
Mannequin

elenaoat mannequin commented Nov 3, 2019

BPO 38669
Nosy @terryjreedy, @cjw296, @voidspace, @elenaoat, @lisroach, @mariocj89, @tirkarthi
PRs
  • bpo-38669: Add check for the type of target #17034
  • [3.8] bpo-38669: patch.object now raises a helpful error (GH17034) #17510
  • [3.7] bpo-38669: patch.object now raises a helpful error (GH17034) #17511
  • 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 2019-12-09.07:00:24.292>
    created_at = <Date 2019-11-03.02:30:39.464>
    labels = ['type-feature', 'tests', '3.9']
    title = 'patch.object should raise another error when first argument is a str'
    updated_at = <Date 2019-12-09.07:00:24.291>
    user = 'https://github.com/elenaoat'

    bugs.python.org fields:

    activity = <Date 2019-12-09.07:00:24.291>
    actor = 'cjw296'
    assignee = 'none'
    closed = True
    closed_date = <Date 2019-12-09.07:00:24.292>
    closer = 'cjw296'
    components = ['Tests']
    creation = <Date 2019-11-03.02:30:39.464>
    creator = 'Elena.Oat'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 38669
    keywords = ['patch']
    message_count = 5.0
    messages = ['355886', '356258', '358023', '358057', '358058']
    nosy_count = 7.0
    nosy_names = ['terry.reedy', 'cjw296', 'michael.foord', 'Elena.Oat', 'lisroach', 'mariocj89', 'xtreak']
    pr_nums = ['17034', '17510', '17511']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue38669'
    versions = ['Python 3.9']

    @elenaoat
    Copy link
    Mannequin Author

    elenaoat mannequin commented Nov 3, 2019

    When using patch.object with first argument as a string, e.g.
    ´´patch.object('SomeClass', 'somemethod')´´ this raises ´´AttributeError: Something does not have the attribute 'do_something'´´.
    This should instead warn user that the correct type for the first argument is a class.

    @elenaoat elenaoat mannequin added 3.7 (EOL) end of life 3.8 only security fixes 3.9 only security fixes tests Tests in the Lib/test dir labels Nov 3, 2019
    @terryjreedy
    Copy link
    Member

    This enhancement request (no backports) is about the unittest.mock patch.object.
    https://docs.python.org/3/library/unittest.mock.html#unittest.mock.patch.object

    @terryjreedy terryjreedy added type-feature A feature request or enhancement and removed 3.7 (EOL) end of life 3.8 only security fixes labels Nov 8, 2019
    @cjw296
    Copy link
    Contributor

    cjw296 commented Dec 8, 2019

    New changeset cd90a52 by Chris Withers (Elena Oat) in branch 'master':
    bpo-38669: patch.object now raises a helpful error (GH17034)
    cd90a52

    @cjw296
    Copy link
    Contributor

    cjw296 commented Dec 9, 2019

    New changeset 4594565 by Chris Withers (Miss Islington (bot)) in branch '3.8':
    bpo-38669: patch.object now raises a helpful error (GH17510)
    4594565

    @cjw296
    Copy link
    Contributor

    cjw296 commented Dec 9, 2019

    New changeset 41973c9 by Chris Withers (Miss Islington (bot)) in branch '3.7':
    bpo-38669: patch.object now raises a helpful error (GH17511)
    41973c9

    @cjw296 cjw296 closed this as completed Dec 9, 2019
    @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 tests Tests in the Lib/test dir type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants