Skip to content

bpo-38136: Updates await_count and call_count to be different things#16192

Merged
lisroach merged 8 commits intopython:masterfrom
lisroach:fix_call_count
Sep 24, 2019
Merged

bpo-38136: Updates await_count and call_count to be different things#16192
lisroach merged 8 commits intopython:masterfrom
lisroach:fix_call_count

Conversation

@lisroach
Copy link
Copy Markdown
Contributor

@lisroach lisroach commented Sep 16, 2019

After a lot of discussion we have decided that "calls" and "awaits" should be counted as two different things.

To accomplish this I separated the call counting from the actual execution of the call, that way they are counted at two different times. For synchronous calls the increment and execute calls happen one immediately after another, but for asynchronous calls the increment count for call count happens first, and then only after await is called does the call execute and increment the await counters.

https://bugs.python.org/issue38136

Comment thread Lib/unittest/test/testmock/testasync.py Outdated
@tirkarthi
Copy link
Copy Markdown
Member

Does this mean we have to revert the doc updated added in #15761 ?

@lisroach
Copy link
Copy Markdown
Contributor Author

@tirkarthi yes, I can actually just remove that doc change with this PR.


mocks = [
Mock, MagicMock, NonCallableMock, NonCallableMagicMock
Mock, MagicMock, NonCallableMock, NonCallableMagicMock, AsyncMock
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have been thinking to add this. Thanks for doing it. It also needs to be added for EventMock in the other PR just to make sure there is no regression.

Comment thread Lib/unittest/test/testmock/testasync.py Outdated
Comment thread Lib/unittest/test/testmock/testasync.py
Comment thread Lib/unittest/test/testmock/testasync.py
Comment thread Lib/unittest/test/testmock/testasync.py
Comment thread Lib/unittest/test/testmock/testasync.py
Comment thread Lib/unittest/test/testmock/testasync.py Outdated
Comment thread Lib/unittest/test/testmock/testasync.py
Comment thread Lib/unittest/test/testmock/testasync.py Outdated
Comment thread Lib/unittest/test/testmock/testasync.py Outdated
Comment thread Misc/NEWS.d/next/Library/2019-09-16-09-54-42.bpo-38136.MdI-Zb.rst
@bedevere-bot
Copy link
Copy Markdown

When you're done making the requested changes, leave the comment: I have made the requested changes; please review again.

Comment thread Lib/unittest/test/testmock/testasync.py Outdated
Comment thread Lib/unittest/test/testmock/testasync.py
Comment thread Lib/unittest/test/testmock/testasync.py Outdated
Comment thread Lib/unittest/test/testmock/testasync.py Outdated
Comment thread Misc/NEWS.d/next/Library/2019-09-16-09-54-42.bpo-38136.MdI-Zb.rst
@lisroach lisroach merged commit ef04851 into python:master Sep 24, 2019
@lisroach lisroach deleted the fix_call_count branch September 24, 2019 03:49
@miss-islington
Copy link
Copy Markdown
Contributor

Thanks @lisroach for the PR 🌮🎉.. I'm working now to backport this PR to: 3.8.
🐍🍒⛏🤖

@miss-islington
Copy link
Copy Markdown
Contributor

Sorry, @lisroach, I could not cleanly backport this to 3.8 due to a conflict.
Please backport using cherry_picker on command line.
cherry_picker ef048517755db1f0d211fb6dfc655a8b412cc96f 3.8

lisroach added a commit to lisroach/cpython that referenced this pull request Sep 26, 2019
@bedevere-bot
Copy link
Copy Markdown

GH-16431 is a backport of this pull request to the 3.8 branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants