Skip to content

Attaching a PropertyMock records calls #65454

Closed

Description

@voidspace
BPO 21255
Nosy @merwok, @voidspace, @kushaldas, @tirkarthi

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 = None
created_at = <Date 2014-04-16.16:19:15.626>
labels = ['type-bug', 'library']
title = 'Attaching a PropertyMock records calls'
updated_at = <Date 2020-02-18.09:21:36.362>
user = 'https://github.com/voidspace'

bugs.python.org fields:

activity = <Date 2020-02-18.09:21:36.362>
actor = 'xtreak'
assignee = 'michael.foord'
closed = False
closed_date = None
closer = None
components = ['Library (Lib)']
creation = <Date 2014-04-16.16:19:15.626>
creator = 'michael.foord'
dependencies = []
files = []
hgrepos = []
issue_num = 21255
keywords = []
message_count = 3.0
messages = ['216488', '216603', '217006']
nosy_count = 4.0
nosy_names = ['eric.araujo', 'michael.foord', 'kushal.das', 'xtreak']
pr_nums = []
priority = 'normal'
resolution = None
stage = 'needs patch'
status = 'open'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue21255'
versions = ['Python 3.4', 'Python 3.5']

Linked PRs

Activity

  1. voidspace commented on Apr 16, 2014

    @voidspace
    ContributorAuthor

    What steps will reproduce the problem?

        >>> foo = Mock(name='foo')
        >>> prop = PropertyMock(name='prop')
        >>> type(foo).prop = prop
        >>> foo.attach_mock(prop, 'prop')
        >>> foo.mock_calls
        [call.prop(<PropertyMock name='foo.prop' id='4300017296'>)]

    Expected:

        >>> foo.mock_calls
        []

    What version of the product are you using? On what operating system?

    % pip freeze | grep mock
    mock==1.0.1
    
    OS X 10.8.4
    

    Please provide any additional information below.

    It would be even cooler if attaching a property mock made calls to the property appear in the mock_calls for the hosting mock without having to attach it, the way it does with a non-property method :)
    
    I use mock every day now and am firmly of the opinion it is far, far more awesome than sliced bread. Thanks for making it available to the Python community :)
    
  2. self-assigned this
    on Apr 16, 2014
  3. added
    stdlib
    type-bug
    on Apr 16, 2014
  4. merwok commented on Apr 16, 2014

    @merwok
    Member

    >> type(foo).prop = prop
    >>> foo.attach_mock(prop, 'prop')

    Are both of these lines needed?

  5. voidspace commented on Apr 22, 2014

    @voidspace
    ContributorAuthor

    Not sure, but I guess it would be easy to find out. It will need some digging into to find out where the actual bug is. It shouldn't be hard to find though.

  6. transferred this issue fromon Apr 10, 2022
  7. added a commit that references this issue on Jun 4, 2024
  8. added a commit that references this issue on Jun 11, 2024
  9. added 2 commits that reference this issue on Jun 11, 2024
  10. added 2 commits that reference this issue on Jun 11, 2024
  11. hugovk commented on Jun 15, 2024

    @hugovk
    Member

    @blhsing Thank you for fixing a 10-year-old issue! 🎉

  12. added a commit that references this issue on Jun 30, 2024
  13. added a commit that references this issue on Jul 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

stdlibtype-bug

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions