[issue21478] mock calls don't propagate to parent (autospec)

2019-10-16 Thread Karthikeyan Singaravelan
Karthikeyan Singaravelan added the comment: Please open a new issue. It's getting little hard to track on this since it was closed and has 2 PRs merged. -- ___ Python tracker

[issue21478] mock calls don't propagate to parent (autospec)

2019-10-16 Thread Caris Moses
Caris Moses added the comment: I believe I have found another bug related to this issue. I can start a new issue if necessary. When I use some_mock.attach_mock(...) and make calls, the resulting some_mock.call_args is None while the some_mock.mock_calls list is not empty. The code below

[issue21478] mock calls don't propagate to parent (autospec)

2019-10-15 Thread Caris Moses
Caris Moses added the comment: I see. Thanks for your help! -- ___ Python tracker ___ ___ Python-bugs-list mailing list

[issue21478] mock calls don't propagate to parent (autospec)

2019-10-15 Thread Karthikeyan Singaravelan
Karthikeyan Singaravelan added the comment: It needs to approved and merged by a core dev so that it will be available by 3.7.6 and 3.8.1. To clarify the calls are recorded in 3.7.5 and 3.8.0 in mock_calls. It's a problem with assert_has_calls and autospec. As a workaround you can turn off

[issue21478] mock calls don't propagate to parent (autospec)

2019-10-15 Thread Caris Moses
Caris Moses added the comment: Great, thanks so much. It works with the patch. So will this patch be included in the next released version of Python? -- ___ Python tracker

[issue21478] mock calls don't propagate to parent (autospec)

2019-10-15 Thread Karthikeyan Singaravelan
Karthikeyan Singaravelan added the comment: Thanks for the confirmation. You can download the patch for the PR by appending .diff/.patch to the PR URL. The patch can be applied to your source locally with "git apply patch_file" to run my example. Reverting patch would cause AttributeError

[issue21478] mock calls don't propagate to parent (autospec)

2019-10-15 Thread Caris Moses
Caris Moses added the comment: I am having some trouble figuring out how to use CPython to get the exact PR you tested on since I've never used CPython before. However, when I just install Python 3.7.5RC1 and 3.8.0RC1 from the binaries and run your code I do get the AttributeError. And when

[issue21478] mock calls don't propagate to parent (autospec)

2019-10-14 Thread Karthikeyan Singaravelan
Karthikeyan Singaravelan added the comment: I tried your example as below using __name__. I received an AttributeError for which issue38473 in 3.7.5RC1 and 3.8.0RC1 and opened issue38473 and I am running my below code under that issue PR. For 3.7.4, I received manager.mock_calls to be an

[issue21478] mock calls don't propagate to parent (autospec)

2019-10-11 Thread Caris Moses
Caris Moses added the comment: I tried it with mocked functions instead of methods and got the same result, so I dug into this a little deeper. It seems as though the issue it how the mocked functions are called. If I replace the do_something() line with the following then it works.

[issue21478] mock calls don't propagate to parent (autospec)

2019-10-11 Thread Karthikeyan Singaravelan
Karthikeyan Singaravelan added the comment: Oh well :( My initial guess is that the report is for methods. The other reports were for functions. So I am wondering if the check for FunctionType is successful and if I need to handle something more. I haven't tried it yet. --

[issue21478] mock calls don't propagate to parent (autospec)

2019-10-11 Thread Caris Moses
Caris Moses added the comment: Hello, I am still running into this issue. I have tested the following code with Python 3.7.4, 3.7.5rc1 , and 3.8.0rc1. from unittest import TestCase from unittest.mock import patch, Mock, call class MyObject: def __init__(self): self.foo = 0

[issue21478] mock calls don't propagate to parent (autospec)

2019-07-22 Thread Karthikeyan Singaravelan
Karthikeyan Singaravelan added the comment: Thanks Jack for the report. Thanks Mario and Chris for reviews. I am closing this as resolved. -- resolution: -> fixed stage: patch review -> resolved status: open -> closed ___ Python tracker

[issue21478] mock calls don't propagate to parent (autospec)

2019-07-22 Thread Chris Withers
Chris Withers added the comment: New changeset e9b187a2bfbb0586fc5d554ce745b7fe04e0b9a8 by Chris Withers (Miss Islington (bot)) in branch '3.7': bpo-21478: Record calls to parent when autospecced objects are used as child with attach_mock (GH 14688) (GH-14903)

[issue21478] mock calls don't propagate to parent (autospec)

2019-07-22 Thread Chris Withers
Chris Withers added the comment: New changeset 22fd679dc363bfcbda336775da16aff4d6fcb33f by Chris Withers (Miss Islington (bot)) in branch '3.8': bpo-21478: Record calls to parent when autospecced objects are used as child with attach_mock (GH 14688) (GH-14902)

[issue21478] mock calls don't propagate to parent (autospec)

2019-07-22 Thread miss-islington
Change by miss-islington : -- pull_requests: +14680 pull_request: https://github.com/python/cpython/pull/14902 ___ Python tracker ___

[issue21478] mock calls don't propagate to parent (autospec)

2019-07-22 Thread Chris Withers
Chris Withers added the comment: New changeset 7397cda99795a4a8d96193d710105e77a07b7411 by Chris Withers (Xtreak) in branch 'master': bpo-21478: Record calls to parent when autospecced objects are used as child with attach_mock (GH 14688)

[issue21478] mock calls don't propagate to parent (autospec)

2019-07-22 Thread miss-islington
Change by miss-islington : -- pull_requests: +14681 pull_request: https://github.com/python/cpython/pull/14903 ___ Python tracker ___

[issue21478] mock calls don't propagate to parent (autospec)

2019-07-11 Thread Jack Wong
Jack Wong added the comment: Thanks, Karthikeyan! I applied your change to Lib/unittest/mock.py, and it fixed the bug for me. I confirmed that calls to the child mock now appear in the parent's mock_calls in my test suite. Your PR looks good to me. --

[issue21478] mock calls don't propagate to parent (autospec)

2019-07-10 Thread Karthikeyan Singaravelan
Karthikeyan Singaravelan added the comment: > I think a possible fix is to move the inner mock extraction out to the > attach_mock function as that function contains code to clear the mock's > parent and name attributes. Downside is that that would make it fail on > Dmitry's toy example.

[issue21478] mock calls don't propagate to parent (autospec)

2019-07-10 Thread Karthikeyan Singaravelan
Change by Karthikeyan Singaravelan : -- pull_requests: +14493 stage: -> patch review pull_request: https://github.com/python/cpython/pull/14688 ___ Python tracker ___

[issue21478] mock calls don't propagate to parent (autospec)

2019-07-09 Thread Karthikeyan Singaravelan
Karthikeyan Singaravelan added the comment: Thanks Jack for the report. I am reopening this issue. I will use your example as a unit test. I will try to look into it. If you have more cases or examples related to the issue feel free to add them. -- resolution: fixed -> stage:

[issue21478] mock calls don't propagate to parent (autospec)

2019-07-09 Thread Jack Wong
Jack Wong added the comment: Can we reopen this bug? Karthikeyan's PR works for Dmitry's toy example, but it does not work in the usual case where patch() and attach_mock() are used. I encountered this bug on Python 3.7.3, which includes the PR. Non-toy example: import unittest.mock as

[issue21478] mock calls don't propagate to parent (autospec)

2019-03-03 Thread Karthikeyan Singaravelan
Change by Karthikeyan Singaravelan : -- resolution: -> fixed stage: patch review -> resolved status: open -> closed ___ Python tracker ___

[issue21478] mock calls don't propagate to parent (autospec)

2019-03-03 Thread miss-islington
Change by miss-islington : -- pull_requests: +12147 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue21478] mock calls don't propagate to parent (autospec)

2018-12-20 Thread Karthikeyan Singaravelan
Change by Karthikeyan Singaravelan : -- keywords: +patch pull_requests: +10508 stage: needs patch -> patch review ___ Python tracker ___

[issue21478] mock calls don't propagate to parent (autospec)

2018-12-20 Thread Karthikeyan Singaravelan
Karthikeyan Singaravelan added the comment: I think this should be handled in _check_and_set_parent where if value's type is FunctionType then value.mock should be used against which parent and name should be set since create_autospec returns function with mock attached to 'mock' attribute

[issue21478] mock calls don't propagate to parent (autospec)

2015-03-09 Thread Claudiu Popa
Changes by Claudiu Popa pcmantic...@gmail.com: -- nosy: +Claudiu.Popa ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21478 ___ ___ Python-bugs-list

[issue21478] mock calls don't propagate to parent (autospec)

2014-05-12 Thread Dmitry Andreychuk
New submission from Dmitry Andreychuk: Calls to autospecced mock functions are not recorded to mock_calls list of parent mock. This only happens if autospec is used and the original object is a function. Example: import unittest.mock as mock def foo(): pass parent = mock.Mock()

[issue21478] mock calls don't propagate to parent (autospec)

2014-05-12 Thread Ned Deily
Changes by Ned Deily n...@acm.org: -- nosy: +michael.foord ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21478 ___ ___ Python-bugs-list mailing

[issue21478] mock calls don't propagate to parent (autospec)

2014-05-12 Thread Michael Foord
Michael Foord added the comment: Mock objects detect when another mock is added as a child, but they don't currently detect that a function created by autospec has been added. It should be a fairly easy fix. -- assignee: - michael.foord ___ Python

[issue21478] mock calls don't propagate to parent (autospec)

2014-05-12 Thread Michael Foord
Changes by Michael Foord mich...@voidspace.org.uk: -- nosy: +kushal.das stage: - needs patch versions: +Python 3.5 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21478 ___