-
Notifications
You must be signed in to change notification settings - Fork 41
Open
Description
If you patch coroutine in setUp with MagicMock, you can't redefine it as CoroutineMock using "with" syntax. However, you can do it with decorator.
Here is a simple example to reproduce the situation.
class TestTest(asynctest.TestCase):
def setUp(self):
wrong_mock = mock.patch("some.service.coro")
wrong_mock.start()
@asynctest.patch("some.service.coro")
def test_ok(self, coro_mock):
assert isinstance(coro_mock, asynctest.CoroutineMock)
def test_not_ok(self):
with asynctest.patch("some.service.coro") as coro_mock:
assert isinstance(coro_mock, asynctest.CoroutineMock)Metadata
Metadata
Assignees
Labels
No labels