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

Attaching a PropertyMock records calls #65454

Closed
voidspace opened this issue Apr 16, 2014 · 4 comments
Closed

Attaching a PropertyMock records calls #65454

voidspace opened this issue Apr 16, 2014 · 4 comments
Assignees
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@voidspace
Copy link
Contributor

voidspace commented Apr 16, 2014

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

@voidspace
Copy link
Contributor Author

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 :)

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

merwok commented Apr 16, 2014

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

Are both of these lines needed?

@voidspace
Copy link
Contributor Author

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.

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Jun 11, 2024
…eMock.__setattr__ (pythonGH-120019)

(cherry picked from commit 9e9ee50)

Co-authored-by: blhsing <blhsing@gmail.com>
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Jun 11, 2024
…eMock.__setattr__ (pythonGH-120019)

(cherry picked from commit 9e9ee50)

Co-authored-by: blhsing <blhsing@gmail.com>
cjw296 pushed a commit that referenced this issue Jun 11, 2024
…leMock.__setattr__ (GH-120019) (#120337)

gh-65454: avoid triggering call to a PropertyMock in NonCallableMock.__setattr__ (GH-120019)
(cherry picked from commit 9e9ee50)

Co-authored-by: blhsing <blhsing@gmail.com>
cjw296 pushed a commit that referenced this issue Jun 11, 2024
…leMock.__setattr__ (GH-120019) (#120336)

gh-65454: avoid triggering call to a PropertyMock in NonCallableMock.__setattr__ (GH-120019)
(cherry picked from commit 9e9ee50)

Co-authored-by: blhsing <blhsing@gmail.com>
@hugovk
Copy link
Member

hugovk commented Jun 15, 2024

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

@hugovk hugovk closed this as completed Jun 15, 2024
mrahtz pushed a commit to mrahtz/cpython that referenced this issue Jun 30, 2024
noahbkim pushed a commit to hudson-trading/cpython that referenced this issue Jul 11, 2024
estyxx pushed a commit to estyxx/cpython that referenced this issue Jul 17, 2024
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-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

3 participants