@@ -246,7 +246,6 @@ def _setup_async_mock(mock):
246
246
mock .await_count = 0
247
247
mock .await_args = None
248
248
mock .await_args_list = _CallList ()
249
- mock .awaited = _AwaitEvent (mock )
250
249
251
250
# Mock is not configured yet so the attributes are set
252
251
# to a function and then the corresponding mock helper function
@@ -2116,7 +2115,6 @@ def __get__(self, obj, _type=None):
2116
2115
2117
2116
2118
2117
class AsyncMockMixin (Base ):
2119
- awaited = _delegating_property ('awaited' )
2120
2118
await_count = _delegating_property ('await_count' )
2121
2119
await_args = _delegating_property ('await_args' )
2122
2120
await_args_list = _delegating_property ('await_args_list' )
@@ -2130,7 +2128,6 @@ def __init__(self, /, *args, **kwargs):
2130
2128
# It is set through __dict__ because when spec_set is True, this
2131
2129
# attribute is likely undefined.
2132
2130
self .__dict__ ['_is_coroutine' ] = asyncio .coroutines ._is_coroutine
2133
- self .__dict__ ['_mock_awaited' ] = _AwaitEvent (self )
2134
2131
self .__dict__ ['_mock_await_count' ] = 0
2135
2132
self .__dict__ ['_mock_await_args' ] = None
2136
2133
self .__dict__ ['_mock_await_args_list' ] = _CallList ()
@@ -2159,7 +2156,6 @@ async def proxy():
2159
2156
self .await_count += 1
2160
2157
self .await_args = _call
2161
2158
self .await_args_list .append (_call )
2162
- await self .awaited ._notify ()
2163
2159
2164
2160
return await proxy ()
2165
2161
@@ -2890,35 +2886,3 @@ async def __anext__(self):
2890
2886
except StopIteration :
2891
2887
pass
2892
2888
raise StopAsyncIteration
2893
-
2894
-
2895
- class _AwaitEvent :
2896
- def __init__ (self , mock ):
2897
- self ._mock = mock
2898
- self ._condition = None
2899
-
2900
- async def _notify (self ):
2901
- condition = self ._get_condition ()
2902
- try :
2903
- await condition .acquire ()
2904
- condition .notify_all ()
2905
- finally :
2906
- condition .release ()
2907
-
2908
- def _get_condition (self ):
2909
- """
2910
- Creation of condition is delayed, to minimize the chance of using the
2911
- wrong loop.
2912
- A user may create a mock with _AwaitEvent before selecting the
2913
- execution loop. Requiring a user to delay creation is error-prone and
2914
- inflexible. Instead, condition is created when user actually starts to
2915
- use the mock.
2916
- """
2917
- # No synchronization is needed:
2918
- # - asyncio is thread unsafe
2919
- # - there are no awaits here, method will be executed without
2920
- # switching asyncio context.
2921
- if self ._condition is None :
2922
- self ._condition = asyncio .Condition ()
2923
-
2924
- return self ._condition
0 commit comments