
    dafq                        d dl Z d dlZd dlZd dlZd dlZd dlmZ d dlmZ  ej                  d       d dl m
Z
mZ d dlmZ d dlmZmZmZmZmZmZmZmZmZmZ d	 Z G d
 d      Z G d d      Zd Zd Zd Z G d de      Ze  dZ!e  dZ"ed        Z# G d dejH                        Z% G d dejH                        Z& G d dejH                        Z' G d dejH                        Z( G d dejH                        Z) G d  d!ejH                        Z* G d" d#e      Z+ G d$ d%ejH                        Z, G d& d'ejH                        Z- G d( d)ejH                        Z. G d* d+ejH                        Z/e d,k(  r ej`                          yy)-    N)contextmanager)supportT)module)runiscoroutinefunction)IsolatedAsyncioTestCase)
ANYcall	AsyncMockpatch	MagicMockMockcreate_autospecsentinel	_CallListsealc                  .    t        j                  d        y N)asyncioset_event_loop_policy     @/root/Python-3.12.4/Lib/test/test_unittest/testmock/testasync.pytearDownModuler      s    !!$'r   c                   >    e Zd Zd Zd Zd Zed        Zed        Z	y)
AsyncClassc                      y r   r   selfs    r   __init__zAsyncClass.__init__   s    r   c                    K   y wr   r   r   s    r   async_methodzAsyncClass.async_method   s     $   c                      y r   r   r   s    r   normal_methodzAsyncClass.normal_method       Tr   c                    K   y wr   r   )clss    r   async_class_methodzAsyncClass.async_class_method   s	     '+r#   c                     K   y wr   r   r   r   r   async_static_methodzAsyncClass.async_static_method   s	     %)r#   N)
__name__
__module____qualname__r    r"   r%   classmethodr)   staticmethodr+   r   r   r   r   r      s'    &!+ +) )r   r   c                       e Zd Zd Zy)AwaitableClassc              #      K   d  y wr   r   r   s    r   	__await__zAwaitableClass.__await__"   s        N)r,   r-   r.   r4   r   r   r   r2   r2   !   s    r   r2   c                     K   y wr   r   r   r   r   
async_funcr7   $   s     r#   c                   K   y wr   r   )abcs      r   async_func_argsr<   &        tr#   c                       y r   r   r   r   r   normal_funcr?   (       4r   c                       e Zd Zd Zy)NormalClassc                      y r   r   r   s    r   r9   zNormalClass.a+   s    r   N)r,   r-   r.   r9   r   r   r   rB   rB   *   s    r   rB   z.AsyncClassz.NormalClassc              #      K   | j                  t        d      5  d  t        j                          d d d        y # 1 sw Y   y xY ww)Nzwas never awaited$)assertWarnsRegexRuntimeWarninggccollect)tests    r   assertNeverAwaitedrJ   2   s9     			~/C	D  	

	  s   A;	AA Ac                   0    e Zd Zd Zd Zd Zd Zd Zd Zy)AsyncPatchDecoratorTestc                 X     t        j                  t        d       fd       } |        y )Nr"   c                 :    j                  t        |              y r   )
assertTruer   mock_methodr   s    r   
test_asynczLAsyncPatchDecoratorTest.test_is_coroutine_function_patch.<locals>.test_async=   s    OO/<=r   r   objectr   r   rR   s   ` r    test_is_coroutine_function_patchz8AsyncPatchDecoratorTest.test_is_coroutine_function_patch<   s%    	j.	1	> 
2	>r   c                      t        j                  t        d       fd       }t        t         d       fd       } |         |        y )Nr"   c                 r     |        }j                  t        j                  |             t        |       y r   rO   inspectisawaitabler   rQ   mr   s     r   rR   z?AsyncPatchDecoratorTest.test_is_async_patch.<locals>.test_asyncC   (    AOOG//23Fr   z.async_methodc                 r     |        }j                  t        j                  |             t        |       y r   rY   r\   s     r   test_no_parent_attributezMAsyncPatchDecoratorTest.test_is_async_patch.<locals>.test_no_parent_attributeI   r^   r   )r   rT   r   async_foo_name)r   rR   r`   s   `  r   test_is_async_patchz+AsyncPatchDecoratorTest.test_is_async_patchB   sN    	j.	1	 
2	
 
.!/	0	 
1	
 	 "r   c                 X     t        j                  t        d       fd       } |        y )Nr"   c                 2    j                  | t               y r   assertIsInstancer   rP   s    r   rR   zCAsyncPatchDecoratorTest.test_is_AsyncMock_patch.<locals>.test_asyncS       !!+y9r   rS   rU   s   ` r   test_is_AsyncMock_patchz/AsyncPatchDecoratorTest.test_is_AsyncMock_patchR   s'    	j.	1	: 
2	: 	r   c                 X     t        j                  t        d       fd       } |        y )Nr+   c                 2    j                  | t               y r   re   rP   s    r   rR   zPAsyncPatchDecoratorTest.test_is_AsyncMock_patch_staticmethod.<locals>.test_asyncZ   rg   r   rS   rU   s   ` r   $test_is_AsyncMock_patch_staticmethodz<AsyncPatchDecoratorTest.test_is_AsyncMock_patch_staticmethodY   s(    	j"7	8	: 
9	: 	r   c                 X     t        j                  t        d       fd       } |        y )Nr)   c                 2    j                  | t               y r   re   rP   s    r   rR   zOAsyncPatchDecoratorTest.test_is_AsyncMock_patch_classmethod.<locals>.test_asynca   rg   r   rS   rU   s   ` r   #test_is_AsyncMock_patch_classmethodz;AsyncPatchDecoratorTest.test_is_AsyncMock_patch_classmethod`   s(    	j"6	7	: 
8	: 	r   c                      t        t         dd      t        t         dd       fd              }t         |               j                  t	        j
                  t                     y )N.async_func   return_value.async_func_args   c                 ~  K   j                  | j                  d       j                  |j                  d       j                  t        t               j                  t
        t               j                  t                d {   d       j                  t        ddd       d {   d       y 7 07 w)Nr<   r7   rq   ru      r;   )assertEqual
_mock_namerf   r7   r   r<   )func_args_mock	func_mockr   s     r   rR   z@AsyncPatchDecoratorTest.test_async_def_patch.<locals>.test_asynch   s      ^668IJY11<@!!*i8!!/9=:</3?1a1#==qA 0=s$   BB=B9	%B=.B;/B=;B=)r   r,   r   rO   rZ   r   r7   rU   s   ` r   test_async_def_patchz,AsyncPatchDecoratorTest.test_async_def_patchg   s_    	(;'a	8	(+,1	=	B 
> 
9	B 	JL33J?@r   N)	r,   r-   r.   rV   rb   rh   rk   rn   r}   r   r   r   rL   rL   ;   s!    # Ar   rL   c                   0    e Zd Zd Zd Zd Zd Zd Zd Zy)AsyncPatchCMTestc                       fd} |        y )Nc                      t        j                  t        d      5 } j                  t	        |              d d d        y # 1 sw Y   y xY wNr"   )r   rT   r   rO   r   rP   s    r   rR   z>AsyncPatchCMTest.test_is_async_function_cm.<locals>.test_asyncz   s>    j.9 B[ 3K @AB B Bs   A  A	r   rU   s   ` r   test_is_async_function_cmz*AsyncPatchCMTest.test_is_async_function_cmy   s    	B 	r   c                       fd} |        y )Nc                      t        j                  t        d      5 }  |        }j                  t	        j
                  |             t        |       d d d        y # 1 sw Y   y xY wr   )r   rT   r   rO   rZ   r[   r   r\   s     r   rR   z5AsyncPatchCMTest.test_is_async_cm.<locals>.test_async   sM    j.9 [M 3 3A 67A  s   7AA%r   rU   s   ` r   test_is_async_cmz!AsyncPatchCMTest.test_is_async_cm   s    	 	r   c                       fd} |        y )Nc                      t        j                  t        d      5 } j                  | t               d d d        y # 1 sw Y   y xY wr   )r   rT   r   rf   r   rP   s    r   rR   z9AsyncPatchCMTest.test_is_AsyncMock_cm.<locals>.test_async   s8    j.9 >[%%k9=> > >s	   <Ar   rU   s   ` r   test_is_AsyncMock_cmz%AsyncPatchCMTest.test_is_AsyncMock_cm   s    	> 	r   c                 0      fd}t         |              y )Nc                     K   t        t         dt                     5   j                  t        t               d d d         j                  t        j                  t                     y # 1 sw Y   2xY ww)Nrp   )r   r,   r   rf   r7   rO   rZ   r   r   s   r   rR   z6AsyncPatchCMTest.test_async_def_cm.<locals>.test_async   sU     (;/= =%%j)<=OOG77
CD= =s   A7A+1A7+A40A7r   rU   s   ` r   test_async_def_cmz"AsyncPatchCMTest.test_async_def_cm   s    	E
 	JLr   c                      ddit        j                  ddi       fd       } j                  t        |             t	         |              y )Nr9   r:   c                  8   K   j                   d   d       y wNr9   r:   )ry   foor   s   r   rR   z>AsyncPatchCMTest.test_patch_dict_async_def.<locals>.test_async   s     SXs+s   )r   dictrO   r   r   r   rR   r   s   ` @r   test_patch_dict_async_defz*AsyncPatchCMTest.test_patch_dict_async_def   sK    Cj	C#s	$	, 
%	, 	+J78JLr   c                 <     ddi fd}t         |              y )Nr9   c                     K   t        j                   ddi      5  j                   d   d       d d d        y # 1 sw Y   y xY wwr   )r   r   ry   r   s   r   rR   zFAsyncPatchCMTest.test_patch_dict_async_def_context.<locals>.test_async   sA     C#s, 0  S3/0 0 0s   A;	AA Ar   r   s   ` @r   !test_patch_dict_async_def_contextz2AsyncPatchCMTest.test_patch_dict_async_def_context   s    Cj	0 	JLr   N)	r,   r-   r.   r   r   r   r   r   r   r   r   r   r   r   x   s     r   r   c                   *    e Zd Zd Zd Zd Zd Zd Zy)AsyncMockTestc                 L    t               }| j                  t        |             y r   )r   rO   r   r   mocks     r    test_iscoroutinefunction_defaultz.AsyncMockTest.test_iscoroutinefunction_default   s    {+D12r   c                     d }t        |      }| j                  t        |             | j                  t        j                  |             y )Nc                     K   y wr   r   r   r   r   r   z<AsyncMockTest.test_iscoroutinefunction_function.<locals>.foo   s     r#   r   rO   r   rZ   r   r   r   s      r   !test_iscoroutinefunction_functionz/AsyncMockTest.test_iscoroutinefunction_function   s7    ~+D1233D9:r   c                     t               } |       }| j                  t        j                  |             t	        |       | j                  dt        |             y )Nassert_awaited)r   rO   rZ   r[   r   assertIndirr   r   r]   s      r   test_isawaitablezAsyncMockTest.test_isawaitable   sA    {F++A./A&D	2r   c                     d }t        |      }| j                  t        |             | j                  t        j                  |             y )Nc                       y r   r   r   r   r   r   zCAsyncMockTest.test_iscoroutinefunction_normal_function.<locals>.foo   r@   r   r   r   s      r   (test_iscoroutinefunction_normal_functionz6AsyncMockTest.test_iscoroutinefunction_normal_function   s7    ~+D1233D9:r   c                     t        j                         }|j                         }|j                          |j	                          t        |      }| j                  |t         j                         y r   )r   new_event_loopcreate_futurestopcloser   rf   Future)r   loopfutr   s       r   test_future_isfuturez"AsyncMockTest.test_future_isfuture   sM    %%'  "		

~dGNN3r   N)r,   r-   r.   r   r   r   r   r   r   r   r   r   r      s    3;3;4r   r   c                   $    e Zd Zd Zd Zd Zd Zy)AsyncAutospecTestc                      t        t        d       fd       }t        t        d       fd       } |         |        y )NTautospecc                 r    j                  | j                  t               j                  | t               y r   rf   r"   r   r   rP   s    r   rR   z=AsyncAutospecTest.test_is_AsyncMock_patch.<locals>.test_async   s)    !!+":":IF!!+y9r   c                 F    j                  | j                  t               y r   )rf   r%   r   rP   s    r   test_normal_methodzEAsyncAutospecTest.test_is_AsyncMock_patch.<locals>.test_normal_method   s    !!+";";YGr   r   ra   )r   rR   r   s   `  r   rh   z)AsyncAutospecTest.test_is_AsyncMock_patch   sF    	~	-	: 
.	: 
~	-	H 
.	H 	r   c                 z    | j                  t              5  t        t        d       d d d        y # 1 sw Y   y xY w)NT)instance)assertRaisesRuntimeErrorr   r7   r   s    r   test_create_autospec_instancez/AsyncAutospecTest.test_create_autospec_instance   s/    |, 	7J6	7 	7 	7s   1:c                    t        t              } |ddd      fd}| j                  |j                  d       | j	                  |j
                         | j                  |j                  g        |j                          t         |              | j                  t        |             | j                  t        j                               | j                  |j                  d       | j                  |j
                  t        ddd             | j                  |j                  t        ddd      g       |j                          |j                  ddd       |j!                  ddd       |j#                          | j%                  t&              5  |j)                  d       d d d        y # 1 sw Y   y xY w)Nrq   ru   rw   rx   c                  &   K     d {    y 7 wr   r   )	awaitables   r   mainz4AsyncAutospecTest.test_create_autospec.<locals>.main   s     OOs   r   )e)r   r<   ry   await_countassertIsNone
await_argsawait_args_listassert_not_awaitedr   rO   r   r   iscoroutiner
   assert_awaited_onceassert_awaited_once_withassert_awaited_withr   r   AssertionErrorassert_any_await)r   specr   r   s      @r   test_create_autospecz&AsyncAutospecTest.test_create_autospec   sf   /AO		 	))1-$//*--r2!DF+D12++I67))1-$q!q/:--QQ/@A  "%%aa%0  A +~. 	'!!A!&	' 	' 	's   F88Gc                 0      fd}t         |              y )Nc                    K   t        t         dd      5 }  | ddd      }j                  | j                  t               j                  t        |              j                  t        j                  |             j                  t        j                  |             j                  | j                  d       j                  | j                  g        j                  | j                         | j!                          | d {    d d d        j                   j                  d       j                  | j                  t#        ddd             j                  | j                  t#        ddd      g       | j%                          | j'                  ddd       | j)                  ddd       | j+                          | j-                          j                  | j                  d       j                  | j                         j                  | j                  g        y 7 &# 1 sw Y   &xY ww)	Nrt   Tr   rq   ru   rw   rx   r   )r   r,   rf   r   r   rO   r   r   r   rZ   r[   ry   r   r   r   r   r   r
   r   r   r   r   
reset_mock)rQ   r   r   s     r   rR   z>AsyncAutospecTest.test_patch_with_autospec.<locals>.test_async   s    (#34tD  '12	%%k&6&6	B 3K @A 3 3I >? 3 3I >?   !8!8!<  !<!<bA!!+"8"89..0   [44a8[33T!Q!_E[8841?:KL++-00A0;++AqA+6&&(""$[44a8k445[88"=     s0   IC6H7H4H7D!I4H77I<Ir   rU   s   ` r   test_patch_with_autospecz*AsyncAutospecTest.test_patch_with_autospec   s    	>< 	JLr   N)r,   r-   r.   rh   r   r   r   r   r   r   r   r      s    7'6 r   r   c                   Z    e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd Zy)AsyncSpecTestc                       fd}t         t        fD ]'  } j                  d|       5   ||       d d d        ) y # 1 sw Y   4xY w)Nc                      | t               }j                  |j                  t               j                  |j                  t
               y r   )r   rf   r"   r   r%   r   )	mock_typer   r   s     r   
inner_testzCAsyncSpecTest.test_spec_normal_methods_on_class.<locals>.inner_test  s9    Z(D!!$"3"3Y?!!$"4"4i@r   ztest method types with r   r   subTestr   r   r   s   `  r   !test_spec_normal_methods_on_classz/AsyncSpecTest.test_spec_normal_methods_on_class  sU    	A
 $Y/ 	&I 7	{CD &9%& &	&& &	   	>A	c                     t        t              }| j                  |j                  t               | j                  |j
                  t                y r   )r   r   rf   r"   r   r%   r   s     r   +test_spec_normal_methods_on_class_with_mockz9AsyncSpecTest.test_spec_normal_methods_on_class_with_mock&  s8    Jd//;d00$7r   c                    t        t              }t        |       | j                  t              5  |j
                   d d d        | j                  t              5  |j                   d d d        y # 1 sw Y   4xY w# 1 sw Y   y xY wr   )r   r   r   r   AttributeErrorr%   r"   r   s     r   0test_spec_normal_methods_on_class_with_mock_sealz>AsyncSpecTest.test_spec_normal_methods_on_class_with_mock_seal+  sp    JT
~. 		~. 		 		 		 	s   A0A<0A9<Bc                     t               }t        |_        t        |_        t        |      }t        |_        | j                  |j                  t               | j                  |j                  t               y Nspec_set)	r   r7   async_func_attrr?   later_async_func_attrr   rf   r   assertNotIsInstance)r   async_instancemock_async_instances      r   #test_spec_async_attributes_instancez1AsyncSpecTest.test_spec_async_attributes_instance3  sZ    #)3&/:,"N;/9,1AA9M  !4!J!JIVr   c                       fd}t         t        t        fD ]'  } j                  d|       5   ||       d d d        ) y # 1 sw Y   4xY w)Nc                     | t               }j                  ||        t              5  j                  t	        j
                   |                    d d d         | t              }j                  ||        y # 1 sw Y   )xY wNr   r7   rf   rJ   rO   rZ   r[   r?   r   
async_mock	sync_mockr   s      r   r   z8AsyncSpecTest.test_spec_mock_type_kw.<locals>.inner_testA  ss    "
3J!!*i8#D) C 3 3JL ABC "{3I!!)Y7	C Cs   *A>>Bztest spec kwarg with r   r   r   r   r   s   `  r   test_spec_mock_type_kwz$AsyncSpecTest.test_spec_mock_type_kw@  sV    	8 $Y5 	&I 5i[AB &9%& &	&& &   	AA	c                       fd}t         t        t        fD ]'  } j                  d|       5   ||       d d d        ) y # 1 sw Y   4xY w)Nc                     | t               }j                  ||        t              5  j                  t	        j
                   |                    d d d         | t              }j                  ||        y # 1 sw Y   (xY wr   r   r   s      r   r   z@AsyncSpecTest.test_spec_mock_type_positional.<locals>.inner_testO  ss    ":.J!!*i8#D) C 3 3JL ABC "+.I!!)Y7	C Cs   *A<<Bztest spec positional with r   r   s   `  r   test_spec_mock_type_positionalz,AsyncSpecTest.test_spec_mock_type_positionalN  sV    	8 $Y5 	&I :9+FG &9%& &	&& &r   c                     t        t              }| j                  |t                 |       }| j                  t	        j
                  |             t        |       y r   r   r?   rf   rO   rZ   r[   r   r   s      r    test_spec_as_normal_kw_AsyncMockz.AsyncSpecTest.test_spec_as_normal_kw_AsyncMock\  sA    k*dI.F++A./Ar   c                     t        t              }| j                  |t                 |       }| j                  t	        j
                  |             t        |       y r   r  r   s      r   (test_spec_as_normal_positional_AsyncMockz6AsyncSpecTest.test_spec_as_normal_positional_AsyncMockc  sA    %dI.F++A./Ar   c                 \     t        j                  t        dd       fd       } |        y )Nr"   Tr   c                 2    j                  | t               y r   re   rP   s    r   rR   z6AsyncSpecTest.test_spec_async_mock.<locals>.test_asynck  rg   r   rS   rU   s   ` r   test_spec_async_mockz"AsyncSpecTest.test_spec_async_mockj  s)    	j.t	<	: 
=	: 	r   c                 F     t        t        d       fd       } |        y )NTr   c                 r    j                  | t               j                  | j                  t               y r   )rf   r   r"   r   rP   s    r   rR   zIAsyncSpecTest.test_spec_parent_not_async_attribute_is.<locals>.test_asyncr  s)    !!+y9!!+":":IFr   r   rU   s   ` r   'test_spec_parent_not_async_attribute_isz5AsyncSpecTest.test_spec_parent_not_async_attribute_isq  s%    	~D	)	G 
*	G 	r   c                 x     t        j                  t        dt        j                         fd       } |        y )Nr"   r   c                     j                  | t               j                  t        j                  |              j                  t        j
                  |              y r   )rf   r   assertFalserZ   r   r[   rP   s    r   test_async_attributezFAsyncSpecTest.test_target_async_spec_not.<locals>.test_async_attributez  sE    !!+y9W00=>W00=>r   )r   rT   r   rB   r9   )r   r  s   ` r   test_target_async_spec_notz(AsyncSpecTest.test_target_async_spec_noty  s/    	j.{}}	E	? 
F	?
 	r   c                 d     t        j                  t        dt               fd       } |        y )Nr9   r   c                 2    j                  | t               y r   re   )mock_async_funcr   s    r    test_attribute_not_async_spec_iszUAsyncSpecTest.test_target_not_async_spec_is.<locals>.test_attribute_not_async_spec_is  s    !!/9=r   )r   rT   rB   r7   )r   r  s   ` r   test_target_not_async_spec_isz+AsyncSpecTest.test_target_not_async_spec_is  s(    	k3Z	8	> 
9	>(*r   c                 N     t        t        t               fd       } |        y )Nr   c                 r    j                  | j                  t               j                  | t               y r   r   )MockNormalClassr   s    r    test_async_attributes_coroutineszRAsyncSpecTest.test_spec_async_attributes.<locals>.test_async_attributes_coroutines  s)    !!/">">	J!!/9=r   )r   normal_foo_namer   )r   r  s   ` r   test_spec_async_attributesz(AsyncSpecTest.test_spec_async_attributes  s$    	Z	0	> 
1	> 	)*r   N)r,   r-   r.   r   r   r   r   r   r  r  r  r
  r  r  r  r  r   r   r   r   r     sD    &8
W&&++r   r   c                   $    e Zd Zd Zd Zd Zd Zy)AsyncSpecSetTestc                 \     t        j                  t        dd       fd       } |        y )Nr"   Tr   c                 2    j                  | t               y r   re   )r"   r   s    r   rR   z<AsyncSpecSetTest.test_is_AsyncMock_patch.<locals>.test_async  s    !!,	:r   rS   rU   s   ` r   rh   z(AsyncSpecSetTest.test_is_AsyncMock_patch  s(    	j.4	@	; 
A	;r   c                     t        t        j                        }| j                  t	        |             | j                  |t                y r   )r   r   r"   rO   r   rf   r   s     r   test_is_async_AsyncMockz(AsyncSpecSetTest.test_is_async_AsyncMock  s4    *"9"9:+D12dI.r   c                 `   t        t              }| j                  t        |j                               | j                  t        |j                               | j                  |j                  t               | j                  |j                  t                | j                  |t                y r   )	r   r   rO   r   r"   r  r%   rf   r   r   s     r   test_is_child_AsyncMockz(AsyncSpecSetTest.test_is_child_AsyncMock  sz    *-+D,=,=>?,T-?-?@Ad//;d00)<dI.r   c                     t               }t        d       |_        t        j                  |d      5 }| j	                  |t                d d d        y # 1 sw Y   y xY w)Nc                     | S r   r   xs    r   <lambda>z=AsyncSpecSetTest.test_magicmock_lambda_spec.<locals>.<lambda>  s    a r   r   	mock_func)r   r+  r   rT   rf   )r   mock_objcms      r   test_magicmock_lambda_specz+AsyncSpecSetTest.test_magicmock_lambda_spec  sK    ;&K8\\(K0 	1B!!"i0	1 	1 	1s   AAN)r,   r-   r.   rh   r#  r%  r.  r   r   r   r  r    s    /
/1r   r  c                   Z    e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd Zy)AsyncArgumentsc                 t   K   d }t        |d      } |d       d {   }| j                  |d       y 7 w)Nc                    K   y wr   r   )r   vars     r   additionz6AsyncArguments.test_add_return_value.<locals>.addition  r=   r#   
   rr      r   ry   )r   r4  r   outputs       r   test_add_return_valuez$AsyncArguments.test_add_return_value  s5     +3Aw$ s   868c                    K    G d dt               }d }t        | |d            }| j                  |d      5   |d       d {    d d d        y 7 # 1 sw Y   y xY ww)Nc                       e Zd Zy)BAsyncArguments.test_add_side_effect_exception.<locals>.CustomErrorNr,   r-   r.   r   r   r   CustomErrorr<    s    r   r>  c                    K   y wr   r   r3  s    r   r4  z?AsyncArguments.test_add_side_effect_exception.<locals>.addition  s     r#   zside-effectside_effectr6  )	Exceptionr   assertRaisesRegex)r   r>  r4  r   s       r   test_add_side_effect_exceptionz-AsyncArguments.test_add_side_effect_exception  sZ     *)*%{=/IJ##K? 	q'MM	 		 	s.   8A"AAA	A"AAA"c                 r   K   d }t        |      } |d       d {   }| j                  |d       y 7 w)Nc                    K   | dz   S wNrq   r   r@  s    r   r4  z?AsyncArguments.test_add_side_effect_coroutine.<locals>.addition  s     7Nr5   rA  r6     r7  r   r4  r   results       r   test_add_side_effect_coroutinez-AsyncArguments.test_add_side_effect_coroutine  5     	X.Aw#    757c                 r   K   d }t        |      } |d       d {   }| j                  |d       y 7 w)Nc                     | dz   S rH  r   r@  s    r   r4  zEAsyncArguments.test_add_side_effect_normal_function.<locals>.addition  s    7Nr   rA  r6  rI  r7  rJ  s       r   $test_add_side_effect_normal_functionz3AsyncArguments.test_add_side_effect_normal_function  rM  rN  c                    K   g d}t        |      }|D ]!  }| j                   |        d {   |       # | j                  t              5 } |        d {    d d d        y 7 97 # 1 sw Y   y xY ww)Nrq   ru   rw   rA  )r   ry   r   StopAsyncIteration)r   valsr   itemr   s        r   test_add_side_effect_iterablez,AsyncArguments.test_add_side_effect_iterable  sy     T* 	1D46\40	1 12 	a&LL	 	 * 	 	s9   +A7A'
 A7A+A)A+
A7)A++A40A7c                   K    G d dt               }d |d      g}t        |      }| j                   |        d {   d       | j                  |      5 } |        d {    d d d        y 7 37 # 1 sw Y   y xY ww)Nc                       e Zd Zy)OAsyncArguments.test_add_side_effect_exception_iterable.<locals>.SampleExceptionNr=  r   r   r   SampleExceptionrZ    s    r   r[  rq   r   rA  )rC  r   ry   r   )r   r[  rU  r   r   s        r   'test_add_side_effect_exception_iterablez6AsyncArguments.test_add_side_effect_exception_iterable  s     	i 	 ?5)*T*tvq)/ 	1&LL	 	 & 	 	s9   ;BA1BA5#A3$A5(
B3A55A>:Bc                    K   t        d      }t        |      } |        d {   }| j                  ||       y 7 w)Nr5  rr   )r   assertIs)r   valuer   rK  s       r   test_return_value_AsyncMockz*AsyncArguments.test_return_value_AsyncMock  s6     r*e,vfe$    #?=?c                    K   t        j                         }|j                  d        t        |      } |        d {   }| j	                  |t         j                         y 7 %w)Nrr   )r   r   
set_resultr   rf   r   r   r   rK  s       r   test_return_value_awaitablez*AsyncArguments.test_return_value_awaitable  sJ     nntc*vfgnn5 s   <A&A$&A&c                 H  K   t        j                         }|j                  d        t        |g      } |        d {   }| j	                  |t         j                         | j                  t              5   |        d {    d d d        y 7 R7 # 1 sw Y   y xY ww)NrA  )r   r   rc  r   rf   r   rT  rd  s       r   !test_side_effect_awaitable_valuesz0AsyncArguments.test_side_effect_awaitable_values  s     nntcU+vfgnn512 	&LL	 	  	 	s:   =B"B 9B"9BBB	
B"BBB"c                    K   t        d      }t        |      } |        d {   }| j                  |d       y 7 w)Nr5  rr   rA  r7  )r   effectr   rK  s       r   test_side_effect_is_AsyncMockz,AsyncArguments.test_side_effect_is_AsyncMock  s8     +V,v$ ra  c                    K   t        j                         dfd}t        |      } |        d {   }| j                  |       |j	                          | j                         y 7 8w)NFc                     K   d S wNTr   ranr_  s   r   innerz2AsyncArguments.test_wraps_coroutine.<locals>.inner  s     CLs   wraps)r   r   r   ry   r   rO   r   rp  r   rK  ro  r_  s       @@r   test_wraps_coroutinez#AsyncArguments.test_wraps_coroutine  s_      	
 u%v' s   3A2A09A2c                    K   ddfd}t        |      } |        d {   }| j                  |       |j                          | j                         y 7 8w)Nrq   Fc                      d S rm  r   rn  s   r   rp  z8AsyncArguments.test_wraps_normal_function.<locals>.inner  s    CLr   rq  )r   ry   r   rO   rs  s       @@r   test_wraps_normal_functionz)AsyncArguments.test_wraps_normal_function  sX     	
 u%v' s   !A A9A c                 z  K   t               } |d      } |d      }| d {    | d {    |j                  t        d      t        d      g       | j                  |j                  t        d      t        d      g       | j                  |j
                  t        d      t        d      g       y 7 7 w)Nru   rq   )r   assert_has_awaitsr
   ry   r   call_args_list)r   r   mock2mock1s       r   test_await_args_list_orderz)AsyncArguments.test_await_args_list_order  s     [
11$$d1gtAw%7833d1gtAw5GH22T!Wd1g4FG	 	s     B;B7	B;B9BB;9B;N)r,   r-   r.   r9  rE  rL  rQ  rW  r\  r`  re  rg  rj  rt  rw  r}  r   r   r   r0  r0    sD    %$$	%6	%Hr   r0  c                   *    e Zd Zd Zd Zd Zd Zd Zy)AsyncMagicMethodsc                    t               }| j                  |j                  t               | j                  |j                  t               | j                  |j
                  t               | j                  |j                  t                y r   )r   rf   
__aenter__r   	__aexit__	__anext__	__aiter__r   m_mocks     r   +test_async_magic_methods_return_async_mocksz=AsyncMagicMethods.test_async_magic_methods_return_async_mocks(  sc    f//;f..	:f..	: 	f..	:r   c                    t               }| j                  |j                  t               | j                  |j                  t               | j                  |j
                  t               | j                  |j                  t               y r   )r   rf   	__enter__r   __exit____next____len__r   a_mocks     r   *test_sync_magic_methods_return_magic_mocksz<AsyncMagicMethods.test_sync_magic_methods_return_magic_mocks1  s[    f..	:fooy9fooy9fnni8r   c                     t               }| j                  t        |d             | j                  t        |d             | j                  t        |d             y )Nr  r  r  )r   rO   hasattrr  s     r   &test_magicmock_has_async_magic_methodsz8AsyncMagicMethods.test_magicmock_has_async_magic_methods8  sB    564545r   c                     t               }| j                  t        |d             | j                  t        |d             | j                  t        |d             | j                  t        |d             y )Nr  r  r  r  )r   rO   r  r  s     r   %test_asyncmock_has_sync_magic_methodsz7AsyncMagicMethods.test_asyncmock_has_sync_magic_methods>  sU    45
34
34	23r   c                 (   t               }| j                  |j                  t               | j                  |j                  t               | j                  t        |j                               | j                  t        |j                               y r   )r   rf   r  r   r  rO   r   r  s     r   &test_magic_methods_are_async_functionsz8AsyncMagicMethods.test_magic_methods_are_async_functionsE  se    f//;f..	:+F,=,=>?+F,<,<=>r   N)r,   r-   r.   r  r  r  r  r  r   r   r   r  r  '  s    ;964?r   r  c                   f    e Zd Z G d d      Z G d d      Z G d d      Zd Zd Zd	 Zd
 Z	d Z
y)AsyncContextManagerTestc                       e Zd Zd Zd Zy)/AsyncContextManagerTest.WithAsyncContextManagerc                    K   y wr   r   r   argskwargss      r   r  z:AsyncContextManagerTest.WithAsyncContextManager.__aenter__P  s     Tr#   c                    K   y wr   r   r  s      r   r  z9AsyncContextManagerTest.WithAsyncContextManager.__aexit__R  s     Dr#   N)r,   r-   r.   r  r  r   r   r   WithAsyncContextManagerr  O  s    98r   r  c                       e Zd Zd Zd Zy).AsyncContextManagerTest.WithSyncContextManagerc                      y r   r   r  s      r   r  z8AsyncContextManagerTest.WithSyncContextManager.__enter__U  s    dr   c                      y r   r   r  s      r   r  z7AsyncContextManagerTest.WithSyncContextManager.__exit__W  s    Tr   N)r,   r-   r.   r  r  r   r   r   WithSyncContextManagerr  T  s    21r   r  c                       e Zd Zd Zd Zy)&AsyncContextManagerTest.ProductionCodec                     d | _         y r   )sessionr   s    r   r    z/AsyncContextManagerTest.ProductionCode.__init__[  s	    DLr   c                    K   | j                   j                  d      4 d {   }|j                          d {   }|cd d d       d {    S 7 /7 7 	# 1 d {  7  sw Y   y xY ww)Nzhttps://python.org)r  postjson)r   responsevals      r   r   z+AsyncContextManagerTest.ProductionCode.main^  s_     ||(()=>  ($MMO+  +   sT    A-AA-AAA A-AA-AA-A*A!A*&A-N)r,   r-   r.   r    r   r   r   r   ProductionCoder  Y  s    	 	r   r  c                       fd}t         t        fD ]'  } j                  d|       5   ||       d d d        ) y # 1 sw Y   4xY w)Nc                 J   j                         }t        d      |_         | d      }t        d      }t        ddi      |_        ||j
                  _        ||j                  j                  _        t        |j                               }j                  |ddi       y )Nsessionmocknamemagic_cmr  r  {   rr   )r  r   r  r   r  r  rs   r  r   r   ry   )r   pcr-  r  rK  r   s        r   r   zKAsyncContextManagerTest.test_set_return_value_of_aenter.<locals>.inner_testd  s    $$&B"6BJ
+B j1H%FC=AHM)1BMM&+-BJJOO(^FVfc]3r   z%test set return value of aenter with r   r   s   `  r   test_set_return_value_of_aenterz7AsyncContextManagerTest.test_set_return_value_of_aenterc  sT    		4 $Y/ 	&I Ei[QR &9%& &	&& &r   c                       fd}t         t        fD ]'  } j                  d|       5   ||       d d d        ) y # 1 sw Y   4xY w)Nc                    dj                         } | |      fd}t         |             }j                         j                  j                  j                         j                  j
                  j                         j                  j                          j
                  j                          j                  |       y )NFc                  ~   K   4 d {   } dd d d       d {    | S 7 7 # 1 d {  7  sw Y    S xY wwrm  r   )rK  calledcm_mocks    r   use_context_managerzqAsyncContextManagerTest.test_mock_supports_async_context_manager.<locals>.inner_test.<locals>.use_context_managery  sJ     " " "f!F" "" " " " "s0   =#='=%==:0:=)r  r   rO   r  r  r  r   assertIsNot)r   r-  r  	cm_resultr  r  r   s       @@r   r   zTAsyncContextManagerTest.test_mock_supports_async_context_manager.<locals>.inner_testt  s    F--/BmG /12IOOF#OOG..556OOG--445--/,,.Wi0r   z!test context manager magics with r   r   s   `  r   (test_mock_supports_async_context_managerz@AsyncContextManagerTest.test_mock_supports_async_context_managers  sT    	1( $Y/ 	&I A)MN &9%& &	&& &r   c                     | j                         }t        |      t               }|j                  _        fd}| j                  t         |             |       y )Nc                  z   K   4 d {   } | cd d d       d {    S 7 7 # 1 d {  7  sw Y   y xY wwr   r   )rK  mock_instances    r   r  z^AsyncContextManagerTest.test_mock_customize_async_context_manager.<locals>.use_context_manager  s>     $        s0   ;";&;$;;8/8;)r  r   rT   r  rs   r^  r   )r   r   expected_resultr  r  s       @r   )test_mock_customize_async_context_managerzAAsyncContextManagerTest.test_mock_customize_async_context_manager  sN    //1!(+ (0?  -	 	c-/0/Br   c                     ddfd}fd}| j                         }t        |      |_        |_        fd}t	         |              | j                         | j                         y )NFc                     K   dy wrm  r   )r  enter_calleds    r   enter_coroutineziAsyncContextManagerTest.test_mock_customize_async_context_manager_with_coroutine.<locals>.enter_coroutine  s     L   c                     K   dy wrm  r   )r  exit_calleds    r   exit_coroutinezhAsyncContextManagerTest.test_mock_customize_async_context_manager_with_coroutine.<locals>.exit_coroutine  s     Kr  c                  x   K    4 d {    	 d d d       d {    y 7 7 # 1 d {  7  sw Y   y xY wwr   r   )r  s   r   r  zmAsyncContextManagerTest.test_mock_customize_async_context_manager_with_coroutine.<locals>.use_context_manager  s<     $        s0   :!:%:#::7.7:)r  r   r  r  r   rO   )r   r  r  r   r  r  r  r  s        @@@r   8test_mock_customize_async_context_manager_with_coroutinezPAsyncContextManagerTest.test_mock_customize_async_context_manager_with_coroutine  sl    	 	 //1!(+#2 "0	 	!"%$r   c                     d }| j                         }t        |      }| j                  t              5  t	         ||             d d d        y # 1 sw Y   y xY w)Nc                 b   K   | 4 d {    t               7 # 1 d {  7  sw Y   y xY wwr   )	TypeError)context_managers    r   raise_inzYAsyncContextManagerTest.test_context_manager_raise_exception_by_default.<locals>.raise_in  s0     & " "k!" " " "s$   ///,#,/)r  r   r   r  r   )r   r  r   r  s       r   /test_context_manager_raise_exception_by_defaultzGAsyncContextManagerTest.test_context_manager_raise_exception_by_default  sQ    	" //1!(+y) 	)'(	) 	) 	)s   AAN)r,   r-   r.   r  r  r  r  r  r  r  r  r   r   r   r  r  M  s:    9 9
2 2
 & &4C%4)r   r  c                   4    e Zd Z G d de      Zd Zd Zd Zy)AsyncIteratorTestc                       e Zd Zd Zd Zd Zy)#AsyncIteratorTest.WithAsyncIteratorc                     g d| _         y )N)r   	NormalFoobaz)itemsr   s    r   r    z,AsyncIteratorTest.WithAsyncIterator.__init__  s	    4DJr   c                      y r   r   r   s    r   r  z-AsyncIteratorTest.WithAsyncIterator.__aiter__  r&   r   c                    K   y wr   r   r   s    r   r  z-AsyncIteratorTest.WithAsyncIterator.__anext__  s     4r#   N)r,   r-   r.   r    r  r  r   r   r   WithAsyncIteratorr    s    	5 	"'r   r  c                     t        d      g dj                  _        fd}t         |             }| j	                  |g d       y )Ntesterr  rS  c                  F   K   2  cg c3 d {   } | 7 6 c} S c c} w wr   r   )i	mock_iters    r   r   z;AsyncIteratorTest.test_aiter_set_return_value.<locals>.main  s"     %.//A////s$   !
!)r   r  rs   r   ry   )r   r   rK  r  s      @r   test_aiter_set_return_valuez-AsyncIteratorTest.test_aiter_set_return_value  s;    8,	+4	(	0TV+r   c                       fd}t         t        fD ]'  } j                  d|       5   ||       d d d        ) y # 1 sw Y   4xY w)Nc                 V   j                         } | |      }j                  t        |j                               j                  t        |j                               j	                  t        |j
                               j	                  t        |j
                               y r   )r  r  r   r  rO   r  )r   r   r  r   s      r   r   zIAsyncIteratorTest.test_mock_aiter_and_anext_asyncmock.<locals>.inner_test  s    --/H%h/M 01C1CDE01H1HIJOO/0B0BCDOO/0G0GHIr   z%test aiter and anext corourtine with r   r   s   `  r   #test_mock_aiter_and_anext_asyncmockz5AsyncIteratorTest.test_mock_aiter_and_anext_asyncmock  sU    		J $Y/ 	&I Ei[QR &9%& &	&& &r   c                     d g d fd} fd} fd}t         t        fD ]q  } j                  d|       5   ||       d d d         j                  d|       5   ||       d d d         j                  d|       5   ||       d d d        s y # 1 sw Y   VxY w# 1 sw Y   =xY w# 1 sw Y   xY w)	Nc                 R   K   g }| 2 3 d {   }|j                  |       7 6 |S wr   )append)iteratoraccumulatorrV  s      r   iteratez6AsyncIteratorTest.test_mock_async_for.<locals>.iterate  s8     K& ) )d""4()h s   '$"$'$')FOOBARBAZc                 t     | j                               }j                  t         |            g        y r   )r  ry   r   )r   r  r  r   s     r   test_defaultz;AsyncIteratorTest.test_mock_async_for.<locals>.test_default  s0    %d&<&<&>?MS!78"=r   c                      | j                               }d d  |j                  _        j                  t	         |                   y r   )r  r  rs   ry   r   r   r  expectedr  r   s     r   test_set_return_valuezDAsyncIteratorTest.test_mock_async_for.<locals>.test_set_return_value  sB    %d&<&<&>?M3;A;M##0S!78(Cr   c                      | j                               }t        d d        |j                  _        j	                  t         |                   y r   )r  iterr  rs   ry   r   r  s     r   test_set_return_value_iterzIAsyncIteratorTest.test_mock_async_for.<locals>.test_set_return_value_iter  sG    %d&<&<&>?M373DM##0S!78(Cr   zdefault value with zset return_value with zset return_value iterator with r   )r   r  r  r  r   r  r  s   `    @@r   test_mock_async_forz%AsyncIteratorTest.test_mock_async_for  s    	 )	>
	D
	D
 $Y/ 	6I 3I;?@ (Y'(  6ykBC 1%i01  ?	{KL 6*956 6	6( (1 16 6s$   	B '	B,	B8 B)	,B5	8C	N)r,   r-   r.   rT   r  r  r  r  r   r   r   r  r    s    (F (,&" 6r   r  c                       e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zy)AsyncMockAssertc                 "    t               | _        y r   )r   r   r   s    r   setUpzAsyncMockAssert.setUp  s    K	r   c                 D   K    | j                   |i | d {    y 7 wr   )r   r  s      r   _runnable_testzAsyncMockAssert._runnable_test  s     dii((((s     c                 "   K   | d {   S 7 wr   r   )r   	coroutines     r   _await_coroutinez AsyncMockAssert._await_coroutine  s     s   c                 b   t        t              }t        |       5  |j                          d d d        | j	                  t        |j                               |j                  j                          |j                  j                          |j                  j                          | j                  t              5  |j                          d d d        | j                  t              5  |j                  j                          d d d        y # 1 sw Y   xY w# 1 sw Y   NxY w# 1 sw Y   y xY wr   )r   r   rJ   r"   rO   r   assert_calledassert_called_onceassert_called_once_withr   r   r   r   s     r   "test_assert_called_but_not_awaitedz2AsyncMockAssert.test_assert_called_but_not_awaited  s    $% 	 	 +D,=,=>?''),,.113~. 	"!	"~. 	/,,.	/ 	/	  	 	" 	"	/ 	/s#   D;D)D%DD"%D.c                 j   t        t              }|j                         }|j                  j                          |j                  j	                          |j                  j                          | j                  t              5  |j                  j                          d d d        t        | j                  |             |j                  j	                          |j                  j                          |j                  j                          |j                  j                          y # 1 sw Y   xY wr   )r   r   r"   r  r	  r
  r   r   r   r   r  r   r   )r   r   mock_coroutines      r   test_assert_called_then_awaitedz/AsyncMockAssert.test_assert_called_then_awaited  s    $**,''),,.113~. 	/,,.	/ 	D!!.12,,.((*--/224	/ 	/s   D))D2c                    | j                  t              5  | j                  j                          d d d        | j                  t              5  | j                  j	                          d d d        t        | j                                | j                  j                          | j                  j                          y # 1 sw Y   xY w# 1 sw Y   cxY wr   )	r   r   r   r   r  r   r  r	  r   r   s    r   +test_assert_called_and_awaited_at_same_timez;AsyncMockAssert.test_assert_called_and_awaited_at_same_time+  s    ~. 	'II$$&	' ~. 	&II##%	& 	D!"		$$&		%%'	' 	'	& 	&s   B?C?CCc                    t        t              }|j                         }t        |       5  |j                          d d d        | j	                  t
              5  |j                  j                          d d d        |j                  j                          t        | j                  |             |j                  j                          |j                  j                          y # 1 sw Y   xY w# 1 sw Y   ~xY wr   )r   r   r"   rJ   r   r   r   r  r   r  r   r   r   r  s      r   )test_assert_called_twice_and_awaited_oncez9AsyncMockAssert.test_assert_called_twice_and_awaited_once6  s    $%%'	  % 	 	 ~. 	/,,.	/'')D!!),-((*--/	  	 	/ 	/s   C%C1%C.1C:c                 f   t        t              }|j                         }|j                  j                          t	        | j                  |             | j                  t              5  t	        | j                  |             d d d        |j                  j                          y # 1 sw Y   $xY wr   )	r   r   r"   r	  r   r  r   r   r   r  s      r   )test_assert_called_once_and_awaited_twicez9AsyncMockAssert.test_assert_called_once_and_awaited_twiceD  s    $%%'	,,.D!!),-|, 	2%%i01	2 	((*	2 	2s   )B''B0c                    | j                  t              5  | j                  j                          d d d        | j                  t              5  | j                  j	                          d d d        | j                  t
              5  t        | j                  | j                               d d d        | j                  t              5  | j                  j                          d d d        | j                  t              5  | j                  j	                          d d d        y # 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   fxY w# 1 sw Y   y xY wr   )r   r   r   r   r  r  r   r  r   s    r   "test_assert_awaited_but_not_calledz2AsyncMockAssert.test_assert_awaited_but_not_calledN  s   ~. 	'II$$&	'~. 	&II##%	&y) 	2%%dii01	2 ~. 	'II$$&	'~. 	&II##%	& 	&	' 	'	& 	&	2 	2	' 	'	& 	&s;   D$D0%D<E E$D-0D9<EEEc                 >   t        d      g}t        |       5  | j                  d       d d d        | j                  j                  |       | j	                  t
              5  | j                  j                  |       d d d        y # 1 sw Y   ^xY w# 1 sw Y   y xY wNr   )r
   rJ   r   assert_has_callsr   r   ry  )r   kallss     r    test_assert_has_calls_not_awaitsz0AsyncMockAssert.test_assert_has_calls_not_awaits\  s    e% 	IIe			""5)~. 	/II''.	/ 	/	 		/ 	/s   B"BBBc                 
   t        |       5  | j                          d d d        ddi fg}| j                  | j                  j                  |       t        |       5  | j                  d       d d d        t        |       5  | j                  d       d d d        t	               t	        d      t	        d      g}| j                  | j                  j                  |       y # 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   gxY w)N r   r   r  )rJ   r   ry   
mock_callsr
   )r   kalls_empty
mock_kallss      r   0test_assert_has_mock_calls_on_async_mock_no_specz@AsyncMockAssert.test_assert_has_mock_calls_on_async_mock_no_specd  s    % 	IIK	B|n--{;% 	IIe	% 	IIe	vtE{DK8
--z:	 	
	 		 	s#   C!C-C9!C*-C69Dc                    t        t              }t        |       5  |j                          d d d        ddi fg}| j	                  |j                  j
                  |       | j	                  |j
                  t        j                         g       t        |       5  |j                  ddddd       d d d        t               t        ddddd      g}t        j                         t        j                  ddddd      g}| j	                  |j                  j
                  |       | j	                  |j
                  |       y # 1 sw Y   xY w# 1 sw Y   xY w)	Nr  r   rq   ru   rw      r6  )r9   r:   )r   r   rJ   r"   ry   r  r
   )r   a_class_mockr   method_kallsr!  s        r   2test_assert_has_mock_calls_on_async_mock_with_speczBAsyncMockAssert.test_assert_has_mock_calls_on_async_mock_with_specq  s'    ,% 	(%%'	(B|n22=={K0043D3D3F2GH% 	9%%aAa%8	9Q1Q 78'')4+<+<Q1Q+OP
22==|L00*=	( 	(	9 	9s   EEEEc                 4   t        |       5  | j                  j                  dd        d d d        t        |       5  | j                  j                  j                  dt        j
                         d d d        | j                  | j                  j                  dddd ifdd	d
t        j
                  ifgd       | j                  | j                  j                  j                  dd	d
t        j
                  ifgd       y # 1 sw Y   xY w# 1 sw Y   xY w)Nrw   )fishrI  )cake	something)rw   r)  zsomething_else.something)rI  r*  z#method calls not recorded correctly)rJ   r   r+  something_elser   Cakery   method_callsr   s    r    test_async_method_calls_recordedz0AsyncMockAssert.test_async_method_calls_recorded  s    % 	.II-	.% 	FII$$..qx}}.E	F 	//$/'/FG2
 2		3
 	11>>&vx}}.EFG>	@	. 	.	F 	Fs   D6DDDc                      fd} | j                          t               5   j                          d d d        t               5   j                  dd       d d d        t               5   j                  d       d d d         j                   j                           | j                          t        t              }t               5  |j                          d d d        t               5  |j                  dd       d d d        |j                           ||       y # 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   mxY w# 1 sw Y   RxY w)Nc                     d}|D ]L  }t        | |      }j                  |t               j                  |t               j	                  |g        N y )N)rz  r.  r  )getattrrf   r   listry   )r   namesr  attrr   s       r   assert_attrsz:AsyncMockAssert.test_async_arg_lists.<locals>.assert_attrs  sS    DE +tT*%%dI6%%dD1  r*	+r   rq   ru   rw   )r9   )r   rJ   r   r   r   r"   )r   r6  r  s   `  r   test_async_arg_listsz$AsyncMockAssert.test_async_arg_lists  s'   	+ 	TYY% 	IIK	% 	IIaO	% 	IIIN	 			TYY:&% 	"!	"% 	(Q'	( 	V#	 		 		 		" 	"	( 	(s;   D(D4.E E3E(D14D= E	EE!c                     | j                  t              5  | j                  j                          d d d        t	        | j                                | j                  j                          y # 1 sw Y   =xY wr   )r   r   r   r   r   r  r   s    r   test_assert_awaitedz#AsyncMockAssert.test_assert_awaited  sX    ~. 	'II$$&	' 	D!"		  "		' 	's   A--A6c                    | j                  t              5  | j                  j                          d d d        t	        | j                                | j                  j                          t	        | j                                | j                  t              5  | j                  j                          d d d        y # 1 sw Y   xY w# 1 sw Y   y xY wr   )r   r   r   r   r   r  r   s    r   test_assert_awaited_oncez(AsyncMockAssert.test_assert_awaited_once  s    ~. 	,II))+	, 	D!"		%%'D!"~. 	,II))+	, 	,	, 	,	, 	,s   B>C
>C
Cc                 ~   d}| j                  t        |      5  | j                  j                  d       d d d        t	        | j                                d}| j                  t        |      5  | j                  j                  d       d d d        t	        | j                  d             | j                  j                  d       t	        | j                  d             | j                  t              5  | j                  j                  d       d d d        y # 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   y xY w)NzNot awaitedr   zexpected await not foundSomethingElse)rD  r   r   r   r   r  r   )r   msgs     r   test_assert_awaited_withz(AsyncMockAssert.test_assert_awaited_with  s   ##NC8 	1II))%0	1 	D!"(##NC8 	1II))%0	1 	D&'		%%e,D01~. 	1II))%0	1 	1	1 	1
	1 	1	1 	1s#   D.D'6D3D$'D03D<c                    | j                  t              5  | j                  j                  d       d d d        t	        | j                  d             | j                  j                  d       t	        | j                  d             | j                  t              5  | j                  j                  d       d d d        y # 1 sw Y   xY w# 1 sw Y   y xY wr  )r   r   r   r   r   r  r   s    r   test_assert_awaited_once_withz-AsyncMockAssert.test_assert_awaited_once_with  s    ~. 	6II..u5	6 	D&'		**51D&'~. 	6II..u5	6 	6	6 	6	6 	6s   CCCCc                     | j                  t              5  | j                  j                  d       d d d        t	        | j                  d             | j                  t              5  | j                  j                  d       d d d        t	        | j                  d             | j                  j                  d       t	        | j                  d             | j                  j                  d       y # 1 sw Y   xY w# 1 sw Y   xY w)Nr   r  r=  )r   r   r   r   r   r  r   s    r   test_assert_any_waitz$AsyncMockAssert.test_assert_any_wait  s    ~. 	.II&&u-	. 	D&'~. 	.II&&u-	. 	D&'		""5)D01		""5)	. 	.	. 	.s   C8)D8DDc                 j   t        d      t        d      g}| j                  t              5 }| j                  j	                  |       d d d        | j                  t        j                  j                        d       t        | j                  d             | j                  t              5  | j                  j	                  |       d d d        t        | j                  d             | j                  t              5  | j                  j	                  |       d d d        t        | j                  d             | j                  j	                  |       t        | j                  d             | j                  j	                  |       y # 1 sw Y   JxY w# 1 sw Y   xY w# 1 sw Y   xY w)Nr   r  rq   r=  )r
   r   r   r   ry  ry   len	exceptionr  r   r  )r   callsr-  s      r   test_assert_has_awaits_no_orderz/AsyncMockAssert.test_assert_has_awaits_no_order  sH   ed5k*~. 	/"II''.	/R\\../3D&'~. 	/II''.	/ 	D&'~. 	/II''.	/ 	D&'		##E*D01		##E*!	/ 	/
	/ 	/	/ 	/s#   F.FF)FF&)F2c                 ,    G d d      }t        | j                   |       d             | j                  j                  t	        t
        d      g       | j                  j                  t
        d       | j                  j                  t
        d       y )Nc                       e Zd Zd Zy)9AsyncMockAssert.test_awaits_asserts_with_any.<locals>.Fooc                      y r   r   r   others     r   __eq__z@AsyncMockAssert.test_awaits_asserts_with_any.<locals>.Foo.__eq__      Tr   Nr,   r-   r.   rO  r   r   r   FoorK        )r   rR  rq   )r   r  r   ry  r
   r	   r   r   )r   rR  s     r   test_awaits_asserts_with_anyz,AsyncMockAssert.test_awaits_asserts_with_any  sg    	* 	* 	Dq)*		##T#q\N3		%%c1-		""3*r   c                     G d d      }t        |      fd}t         | |       d             j                  t        t        d      g       j                  t        d       j                  t        d       y )Nc                       e Zd Zd Zy)BAsyncMockAssert.test_awaits_asserts_with_spec_and_any.<locals>.Fooc                      y r   r   rM  s     r   rO  zIAsyncMockAssert.test_awaits_asserts_with_spec_and_any.<locals>.Foo.__eq__	  rP  r   NrQ  r   r   r   rR  rW    rS  r   rR  r   c                  ,   K    |   d {    y 7 wr   r   )r  mock_with_specs    r   _custom_mock_runnable_testzYAsyncMockAssert.test_awaits_asserts_with_spec_and_any.<locals>._custom_mock_runnable_test  s      $'''s   	rq   )r   r   ry  r
   r	   r   r   )r   rR  r[  rZ  s      @r   %test_awaits_asserts_with_spec_and_anyz5AsyncMockAssert.test_awaits_asserts_with_spec_and_any  sh    	* 	* #,	( 	&sua01(($sA,8**32''Q/r   c                     t        d      t        d      g}| j                  t              5  | j                  j	                  |d       d d d        t        | j                  d             | j                  t              5  | j                  j	                  |d       d d d        t        | j                  d             | j                  t              5  | j                  j	                  |d       d d d        t        | j                  d             | j                  j	                  |d       t        | j                  d             | j                  j	                  |d       y # 1 sw Y   #xY w# 1 sw Y   xY w# 1 sw Y   xY w)Nr   r  T)	any_orderbamfqux)r
   r   r   r   ry  r   r  )r   rG  s     r   test_assert_has_awaits_orderedz.AsyncMockAssert.test_assert_has_awaits_ordered  sB   ed5k*~. 	?II'''>	? 	D&'~. 	?II'''>	? 	D'(~. 	?II'''>	? 	D&'		##ET#:D&'		##ET#:	? 	?	? 	?	? 	?s#   E+E8F+E58FFc                     | j                   j                          t        | j                                | j	                  t
              5  | j                   j                          d d d        y # 1 sw Y   y xY wr   )r   r   r   r  r   r   r   s    r   test_assert_not_awaitedz'AsyncMockAssert.test_assert_not_awaited(  sV    		$$&D!"~. 	+II((*	+ 	+ 	+s   	A--A6c                    dd}t        |      | _        t        | j                  d             | j	                  t
        dj                  t        j                  d                  5 }| j                  j                  t               g       d d d        | j                  j                  j                         | j	                  t
        dj                  t        j                  d                  5 }| j                  j                  t               t        dd      g       d d d        | j                  |j                  j                  t               y # 1 sw Y   xY w# 1 sw Y   @xY w)	Nc                    K   y wr   r   r(  s    r   fzIAsyncMockAssert.test_assert_has_awaits_not_matching_spec_error.<locals>.f0  s     Tr#   r   rq   z^{}$z6Awaits not found.
Expected: [call()]
Actual: [call(1)]zError processing expected awaits.
Errors: [None, TypeError('too many positional arguments')]
Expected: [call(), call(1, 2)]
Actual: [call(1)]ru   r   )r   r   r   r  rD  r   formatreescapery  r
   r   rF  	__cause__rf   r  )r   rf  r-  s      r   .test_assert_has_awaits_not_matching_spec_errorz>AsyncMockAssert.test_assert_has_awaits_not_matching_spec_error/  s   !1%	D"###II 2 345 	2
 9;II''1	2 	",,001##II,-./ 		> 35II''a(<=		> 	bll44i@'	2 	2		> 		>s   (%E20E!E!E*N)r,   r-   r.   r  r  r  r  r  r  r  r  r  r  r"  r'  r/  r7  r9  r;  r?  rA  rC  rH  rT  r\  ra  rc  rk  r   r   r   r  r    s     )/5 	(0+&/;>@:#	,1"	6*+*+0;&+Ar   r  __main__)1r   rG   rZ   rh  unittest
contextlibr   rI   r   requires_working_socketr   r   r   unittest.mockr	   r
   r   r   r   r   r   r   r   r   r   r   r2   r7   r<   r?   rT   rB   r,   ra   r  rJ   TestCaserL   r   r   r   r   r  r0  r  r  r  r  r   r   r   r   <module>rr     s    	  	  %    t , , ,G G G(	* 	*   + &  :[)Jl+  :Ah// :Az/x(( /d4H%% 4BM)) M`s+H%% s+l1x(( 18wH, wHt$?)) $?Lo)h// o)dB6)) B6JDAh'' DAN
 zHMMO r   