@@ -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
@@ -2102,7 +2101,6 @@ def __get__(self, obj, _type=None):
2102
2101
2103
2102
2104
2103
class AsyncMockMixin (Base ):
2105
- awaited = _delegating_property ('awaited' )
2106
2104
await_count = _delegating_property ('await_count' )
2107
2105
await_args = _delegating_property ('await_args' )
2108
2106
await_args_list = _delegating_property ('await_args_list' )
@@ -2116,7 +2114,6 @@ def __init__(self, /, *args, **kwargs):
2116
2114
# It is set through __dict__ because when spec_set is True, this
2117
2115
# attribute is likely undefined.
2118
2116
self .__dict__ ['_is_coroutine' ] = asyncio .coroutines ._is_coroutine
2119
- self .__dict__ ['_mock_awaited' ] = _AwaitEvent (self )
2120
2117
self .__dict__ ['_mock_await_count' ] = 0
2121
2118
self .__dict__ ['_mock_await_args' ] = None
2122
2119
self .__dict__ ['_mock_await_args_list' ] = _CallList ()
@@ -2145,7 +2142,6 @@ async def proxy():
2145
2142
self .await_count += 1
2146
2143
self .await_args = _call
2147
2144
self .await_args_list .append (_call )
2148
- await self .awaited ._notify ()
2149
2145
2150
2146
return await proxy ()
2151
2147
@@ -2878,35 +2874,3 @@ async def __anext__(self):
2878
2874
except StopIteration :
2879
2875
pass
2880
2876
raise StopAsyncIteration
2881
-
2882
-
2883
- class _AwaitEvent :
2884
- def __init__ (self , mock ):
2885
- self ._mock = mock
2886
- self ._condition = None
2887
-
2888
- async def _notify (self ):
2889
- condition = self ._get_condition ()
2890
- try :
2891
- await condition .acquire ()
2892
- condition .notify_all ()
2893
- finally :
2894
- condition .release ()
2895
-
2896
- def _get_condition (self ):
2897
- """
2898
- Creation of condition is delayed, to minimize the chance of using the
2899
- wrong loop.
2900
- A user may create a mock with _AwaitEvent before selecting the
2901
- execution loop. Requiring a user to delay creation is error-prone and
2902
- inflexible. Instead, condition is created when user actually starts to
2903
- use the mock.
2904
- """
2905
- # No synchronization is needed:
2906
- # - asyncio is thread unsafe
2907
- # - there are no awaits here, method will be executed without
2908
- # switching asyncio context.
2909
- if self ._condition is None :
2910
- self ._condition = asyncio .Condition ()
2911
-
2912
- return self ._condition
0 commit comments