
    ^h                     n   S SK Jr  S SKrS SKrS SKrS SKrS SKJrJrJ	r	J
r
  S SKJrJr  S SKJr  S SKJr  S SKJr  S SKJrJrJr   " S	 S
\5      r " S S\5      r " S S\5      r " S S\5      r " S S5      r " S S\5      r " S S\5      r " S S\5      r \!S:X  a  \RD                  " 5         gg)    )futuresN)Futurechain_futurerun_on_executor"future_set_result_unless_cancelled)utf8
to_unicode)gen)IOStream)	TCPServer)AsyncTestCasebind_unused_portgen_testc                       \ rS rSrS rSrg)MiscFutureTest"   c                    [        5       n[        US5        U R                  UR                  5       S5        U R	                  UR                  5       5        [        5       nUR                  5         UR                  5       n[        US5        U R                  UR                  5       U5        U(       d!  U R                  UR                  5       S5        g g N*   )r   r   assertEqualresultassertFalse	cancelledcancel)selffutis_cancelleds      V/home/james-whalen/.local/lib/python3.13/site-packages/tornado/test/concurrent_test.py'test_future_set_result_unless_cancelled6MiscFutureTest.test_future_set_result_unless_cancelled#   s    h*33r*)h

}}*33,7SZZ\2.      N)__name__
__module____qualname____firstlineno__r   __static_attributes__r"   r!   r   r   r   "   s    /r!   r   c                   4    \ rS rSr\S 5       r\S 5       rSrg)ChainFutureTest2   c                    #    [        5       n[        5       n[        X5        UR                  S5        UI S h  vN nU R                  US5        g  N7fr   )r   r   
set_resultr   )r   r   fut2r   s       r   test_asyncio_futures$ChainFutureTest.test_asyncio_futures3   sC     !8"HSr$ s   6AAAc                    #    [         R                  " 5       n[         R                  " 5       n[        5       n[        X5        [        X#5        UR                  S5        UI S h  vN nU R	                  US5        g  N7fr   )r   r   r   r,   r   )r   r   r-   fut3r   s        r   test_concurrent_futures'ChainFutureTest.test_concurrent_futures<   s^     
 $+>>#3$+NN$4"HST r$ s   A!A=#A;$A=r"   N)r#   r$   r%   r&   r   r.   r2   r'   r"   r!   r   r)   r)   2   s(    % % % %r!   r)   c                   8    \ rS rSr\R
                  S 5       rSrg)	CapServerO   c              #     #    UR                  S5      v n[        U5      nX3R                  5       :X  a  UR                  S5        O+UR                  [	        SUR                  5       -  5      5        UR                  5         g 7f)N   
s   error	already capitalized
zok	%s)
read_untilr	   upperwriter   close)r   streamaddressdatas       r   handle_streamCapServer.handle_streamP   sb     &&u--$::<LL89 LLh567s   B Br"   N)r#   r$   r%   r&   r
   	coroutiner@   r'   r"   r!   r   r5   r5   O   s    ]] r!   r5   c                       \ rS rSrSrg)CapError\   r"   N)r#   r$   r%   r&   r'   r"   r!   r   rD   rD   \   s    r!   rD   c                        \ rS rSrS rS rSrg)BaseCapClient`   c                     Xl         g Nport)r   rL   s     r   __init__BaseCapClient.__init__a   s    	r!   c                     [         R                  " S[        U5      5      nUc  [        S5      eUR	                  5       u  p4US:X  a  U$ [        U5      e)Nz
(.*)	(.*)
zdid not matchok)rematchr	   	ExceptiongroupsrD   )r   r?   mstatusmessages        r   process_responseBaseCapClient.process_responsed   sK    HH^Z%569O,,((*T>N7##r!   rK   N)r#   r$   r%   r&   rM   rX   r'   r"   r!   r   rG   rG   `   s    $r!   rG   c                   8    \ rS rSr\R
                  S 5       rSrg)GeneratorCapCliento   c              #     #    [         R                  " S5        [        [        R                  " 5       5      n[         R                  " S5        UR	                  SU R
                  45      v   UR                  [        US-   5      5        [         R                  " S5        UR                  S5      v n[         R                  " S5        UR                  5         [        R                  " U R                  U5      5      e7f)N
capitalize
connectingz	127.0.0.1
readingr8   	returning)loggingdebugr   socketconnectrL   r;   r   r9   r<   r
   ReturnrX   )r   request_datar=   r?   s       r   r^   GeneratorCapClient.capitalizep   s     l#&--/*l#nnk499566T,-./i &&u--k"jj..t455s   C;C=r"   N)r#   r$   r%   r&   r
   rB   r^   r'   r"   r!   r   r[   r[   o   s    ]]
6 
6r!   r[   c                   L   ^  \ rS rSrU 4S jrU 4S jrS rS rS rS r	Sr
U =r$ )	GeneratorCapClientTest~   c                    > [         TU ]  5         [        5       U l        [	        5       u  pU R                  R                  U/5        [        US9U l        g )NrK   )supersetUpr5   serverr   add_socketsr[   client)r   sockrL   	__class__s      r   ro   GeneratorCapClientTest.setUp   s?    k%'
'(d3r!   c                 V   > U R                   R                  5         [        TU ]  5         g rJ   )rp   stoprn   tearDown)r   rt   s    r   rx   GeneratorCapClientTest.tearDown   s    r!   c                     U R                   R                  S5      nU R                  R                  XR                  5        U R                  5         U R                  UR                  5       S5        g NhelloHELLO)rr   r^   io_loop
add_futurerw   waitr   r   r   futures     r   test_future"GeneratorCapClientTest.test_future   sK    ''0		2		'2r!   c                     U R                   R                  S5      nU R                  R                  XR                  5        U R                  5         U R                  [        SUR                  5        g )Nr}   already capitalized)	rr   r^   r~   r   rw   r   assertRaisesRegexrD   r   r   s     r   test_future_error(GeneratorCapClientTest.test_future_error   sL    ''0		2		x)>Nr!   c                 n   ^  [         R                  U 4S j5       nT R                  R                  U5        g )Nc               3   l   >#    TR                   R                  S5      v n TR                  U S5        g 7fr{   )rr   r^   r   )r   r   s    r   f0GeneratorCapClientTest.test_generator.<locals>.f   s-     ;;11'::FVW-s   14r
   rB   r~   run_syncr   r   s   ` r   test_generator%GeneratorCapClientTest.test_generator   s-    		. 
	. 	a r!   c                 n   ^  [         R                  U 4S j5       nT R                  R                  U5        g )Nc               3      >#    T R                  [        S5         T R                  R                  S5      v   S S S 5        g ! , (       d  f       g = f7f)Nr   r}   )r   rD   rr   r^   r   s   r   r   6GeneratorCapClientTest.test_generator_error.<locals>.f   s8     ''2GHkk,,W55 IHHs   AA	A
AAr   r   s   ` r   test_generator_error+GeneratorCapClientTest.test_generator_error   s-    		6 
	6 	a r!   )rr   rp   )r#   r$   r%   r&   ro   rx   r   r   r   r   r'   __classcell__)rt   s   @r   rk   rk   ~   s'    43O!! !r!   rk   c                   T    \ rS rSr\S 5       r\S 5       r\S 5       r\S 5       rSr	g)RunOnExecutorTest   c              #   v   #     " S S5      nU" 5       nUR                  5       v nU R                  US5        g 7f)Nc                   *    \ rS rSrS r\S 5       rSrg)1RunOnExecutorTest.test_no_calling.<locals>.Object   c                 L    [         R                  R                  S5      U l        g N   r   threadThreadPoolExecutorexecutorr   s    r   rM   :RunOnExecutorTest.test_no_calling.<locals>.Object.__init__        ' A A! Dr!   c                     gr   r"   r   s    r   r   3RunOnExecutorTest.test_no_calling.<locals>.Object.f       r!   r   Nr#   r$   r%   r&   rM   r   r   r'   r"   r!   r   Objectr      s    E  r!   r   r   r   r   r   r   oanswers       r   test_no_calling!RunOnExecutorTest.test_no_calling   5     	 	 Hssu$   79c              #   v   #     " S S5      nU" 5       nUR                  5       v nU R                  US5        g 7f)Nc                   4    \ rS rSrS r\" 5       S 5       rSrg)8RunOnExecutorTest.test_call_with_no_args.<locals>.Object   c                 L    [         R                  R                  S5      U l        g r   r   r   s    r   rM   ARunOnExecutorTest.test_call_with_no_args.<locals>.Object.__init__   r   r!   c                     gr   r"   r   s    r   r   :RunOnExecutorTest.test_call_with_no_args.<locals>.Object.f   r   r!   r   Nr   r"   r!   r   r   r          E  r!   r   r   r   r   s       r   test_call_with_no_args(RunOnExecutorTest.test_call_with_no_args   r   r   c              #   v   #     " S S5      nU" 5       nUR                  5       v nU R                  US5        g 7f)Nc                   2    \ rS rSrS r\" SS9S 5       rSrg)9RunOnExecutorTest.test_call_with_executor.<locals>.Object   c                 L    [         R                  R                  S5      U l        g r   )r   r   r   _Object__executorr   s    r   rM   BRunOnExecutorTest.test_call_with_executor.<locals>.Object.__init__   s    ").."C"CA"Fr!   r   r   c                     gr   r"   r   s    r   r   ;RunOnExecutorTest.test_call_with_executor.<locals>.Object.f   r   r!   )
__executorNr   r"   r!   r   r   r      s"    G &9: ;r!   r   r   r   r   s       r   test_call_with_executor)RunOnExecutorTest.test_call_with_executor   r   r   c              #   r   ^#     " S S5      nU" 5       mU4S jnU" 5       v nU R                  US5        g 7f)Nc                   4    \ rS rSrS r\" 5       S 5       rSrg)2RunOnExecutorTest.test_async_await.<locals>.Object   c                 L    [         R                  R                  S5      U l        g r   r   r   s    r   rM   ;RunOnExecutorTest.test_async_await.<locals>.Object.__init__   r   r!   c                     gr   r"   r   s    r   r   4RunOnExecutorTest.test_async_await.<locals>.Object.f   r   r!   r   Nr   r"   r!   r   r   r      r   r!   r   c                  D   >#    TR                  5       I S h  vN n U $  N7frJ   )r   )r   r   s    r   r   -RunOnExecutorTest.test_async_await.<locals>.f   s     335[FM !s     r   )r   )r   r   r   r   r   s       @r   test_async_await"RunOnExecutorTest.test_async_await   s9     	 	 H	 s$s   47r"   N)
r#   r$   r%   r&   r   r   r   r   r   r'   r"   r!   r   r   r      sP    % % % % % % % %r!   r   __main__)#
concurrentr   rc   rQ   re   unittesttornado.concurrentr   r   r   r   tornado.escaper   r	   tornador
   tornado.iostreamr   tornado.tcpserverr   tornado.testingr   r   r   r   r)   r5   rS   rD   rG   r[   rk   r   r#   mainr"   r!   r   <module>r      s      	    ,  % ' E E/] / %m %:
	 
	y 	$ $6 6&!] &!R<% <%~ zMMO r!   