File tree Expand file tree Collapse file tree 1 file changed +7
-7
lines changed Expand file tree Collapse file tree 1 file changed +7
-7
lines changed Original file line number Diff line number Diff line change 44import asyncio
55import logging
66import unittest
7- from unittest .mock import patch , call
7+ from unittest .mock import patch , call , MagicMock
88
99from hbmqtt .adapters import StreamReaderAdapter , StreamWriterAdapter
1010from hbmqtt .broker import (
4444 }
4545}
4646
47+ # monkey patch MagicMock
48+ # taken from https://stackoverflow.com/questions/51394411/python-object-magicmock-cant-be-used-in-await-expression
49+ async def async_magic ():
50+ pass
51+
52+ MagicMock .__await__ = lambda x : async_magic ().__await__ ()
4753
48- #class AsyncMock(MagicMock):
49- # def __await__(self, *args, **kwargs):
50- # future = asyncio.Future()
51- # future.set_result(self)
52- # result = await future
53- # return result
5454
5555class BrokerTest (unittest .TestCase ):
5656 def setUp (self ):
You can’t perform that action at this time.
0 commit comments