This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Dima.Tisnek
Recipients Dima.Tisnek, asvetlov, fried, lisroach
Date 2020-02-17.02:57:16
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1581908236.72.0.381380569432.issue38857@roundup.psfhosted.org>
In-reply-to
Content
I think this deserves discussion :)

On one hand, it's a welcome change, on another it's kind of a regression.

Up until 3.8, our tests used to look like this:

---
# code under test

async def foo():
    return await bar()


# test

async def helper(value):
    return value


async def test_foo():
    with patch("bar", return_value=helper(42)):
        assert await foo() == 42
---

I feel that the default class `patch()` uses for `new` has crept in too quietly in 3.8.

At the same time, `helper` was only used because there was no `AsyncMock`.
(or at times, a 3rd party library, `asynctest` was used).



So, on one hand, it's a bit of a regression, but on the other, looking ahead, I would really like `unittest.mock` to do the right thing.



Can we have it both ways? If not, what way is a better way?
History
Date User Action Args
2020-02-17 02:57:16Dima.Tisneksetrecipients: + Dima.Tisnek, asvetlov, fried, lisroach
2020-02-17 02:57:16Dima.Tisneksetmessageid: <1581908236.72.0.381380569432.issue38857@roundup.psfhosted.org>
2020-02-17 02:57:16Dima.Tisneklinkissue38857 messages
2020-02-17 02:57:16Dima.Tisnekcreate