o
    u3bó"  ã                   @   sæ   d dl mZ d dlZd dlZd dlZd dlZ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 d dlmZ d dlmZmZmZ g d¢Zdd	„ Zd
d„ ZG dd„ dejƒZG dd„ dejƒZdd„ Zedkrqeƒ  dS dS )é    )ÚreduceN)ÚAsyncHTTPClient)Ú
HTTPServer)ÚResolver)ÚdefineÚadd_parse_callbackÚoptions)#ztornado.httputil.doctestsztornado.iostream.doctestsztornado.util.doctestsztornado.test.asyncio_testztornado.test.auth_testztornado.test.autoreload_testztornado.test.concurrent_testz!tornado.test.curl_httpclient_testztornado.test.escape_testztornado.test.gen_testz!tornado.test.http1connection_testztornado.test.httpclient_testztornado.test.httpserver_testztornado.test.httputil_testztornado.test.import_testztornado.test.ioloop_testztornado.test.iostream_testztornado.test.locale_testztornado.test.locks_testztornado.test.netutil_testztornado.test.log_testztornado.test.options_testztornado.test.process_testztornado.test.queues_testztornado.test.routing_testz#tornado.test.simple_httpclient_testztornado.test.tcpclient_testztornado.test.tcpserver_testztornado.test.template_testztornado.test.testing_testztornado.test.twisted_testztornado.test.util_testztornado.test.web_testztornado.test.websocket_testztornado.test.wsgi_testc                   C   s   t j t¡S ©N)ÚunittestÚdefaultTestLoaderÚloadTestsFromNamesÚTEST_MODULES© r   r   ú7/usr/lib/python3/dist-packages/tornado/test/runtests.pyÚall9   s   r   c                    s   G ‡ fdd„dt jƒ}|S )Nc                       s*   e Zd Z‡ ‡fdd„Z‡ fdd„Z‡  ZS )z2test_runner_factory.<locals>.TornadoTextTestRunnerc                    s   ˆ|d< t ƒ j|i |¤Ž d S )NÚstream)ÚsuperÚ__init__©ÚselfÚargsÚkwargs)Ú	__class__Ústderrr   r   r   ?   s   z;test_runner_factory.<locals>.TornadoTextTestRunner.__init__c              	      sV   t ƒ  |¡}|jr)tdd„ |jD ƒƒ}| j t dd t	|ƒ¡ ¡¡ | j d¡ |S )Nc                 s   s   � | ]\}}|V  qd S r	   r   )Ú.0ÚtestÚreasonr   r   r   Ú	<genexpr>F   s   € zItest_runner_factory.<locals>.TornadoTextTestRunner.run.<locals>.<genexpr>z#Some tests were skipped because: %sz, Ú
)
r   ÚrunÚskippedÚsetr   ÚwriteÚtextwrapÚfillÚjoinÚsorted)r   r   ÚresultÚskip_reasons©r   r   r   r   C   s   ÿÿÿz6test_runner_factory.<locals>.TornadoTextTestRunner.run)Ú__name__Ú
__module__Ú__qualname__r   r   Ú__classcell__r   ©r   r)   r   ÚTornadoTextTestRunner>   s    r/   )r
   ÚTextTestRunner)r   r/   r   r.   r   Útest_runner_factory=   s   r1   c                       s(   e Zd ZdZ‡ fdd„Zdd„ Z‡  ZS )Ú
LogCounterz3Counts the number of WARNING or higher log records.c                    s(   t ƒ j|i |¤Ž d | _ | _| _d S ©Nr   )r   r   Ú
info_countÚwarning_countÚerror_countr   r)   r   r   r   V   s   zLogCounter.__init__c                 C   sZ   |j tjkr|  jd7  _dS |j tjkr|  jd7  _dS |j tjkr+|  jd7  _dS )Né   T)ÚlevelnoÚloggingÚERRORr6   ÚWARNINGr5   ÚINFOr4   )r   Úrecordr   r   r   ÚfilterZ   s   üþzLogCounter.filter)r*   r+   r,   Ú__doc__r   r>   r-   r   r   r)   r   r2   S   s    r2   c                   @   s$   e Zd Zdd„ Zdd„ Zdd„ ZdS )ÚCountingStderrc                 C   s   || _ d| _d S r3   )ÚrealÚ
byte_count)r   rA   r   r   r   r   e   s   
zCountingStderr.__init__c                 C   s   |  j t|ƒ7  _ | j |¡S r	   )rB   ÚlenrA   r"   )r   Údatar   r   r   r"   i   s   zCountingStderr.writec                 C   s
   | j  ¡ S r	   )rA   Úflush)r   r   r   r   rE   m   s   
zCountingStderr.flushN)r*   r+   r,   r   r"   rE   r   r   r   r   r@   d   s    r@   c                     s¼  t  d¡ t jdtd� t jdtd� t jdtd� t jdtdd� t jdtd� t jdtdd� t jdtdd� t jdtdd� t jdtdd� d	tj  k rTd
k r^n nt jdt	dd� t jdtdd� t jdtdd� t jdtdd� t jdtdd� t jdtdd� t
 d¡ t
j¡ tdtd dd„ d� tdtd tjd� tdtd tjd� tdtdddd„ d� tdddd� d d!„ } td"td | d� tƒ ‰ t‡ fd#d„ƒ tj}t|ƒ}|t_d$d l}i }d%|d&< t|ƒ|d'< z>|jjd*i |¤Ž W ˆ jd$k�sˆ jd$k�sˆ jd$k�s|jd$k�r+t
 d(ˆ jˆ jˆ j|j¡ t j!�r)t "d)¡ d S d S d S ˆ jd$k�sEˆ jd$k�sEˆ jd$k�sE|jd$k�r]t
 d(ˆ jˆ jˆ j|j¡ t j!�r\t "d)¡ w w w )+NÚerrorÚignore)Úcategoryztornado\..*)rH   ÚmodulezPlease use assert.* instead)rH   Úmessageztwisted\..*)é   )rK   é   zasyncio\..*z!PY_SSIZE_T_CLEAN will be requiredzThere is no current event loopzssl\.PROTOCOL_TLS is deprecatedz&ssl\.wrap_socket\(\) is deprecated, .*z8ssl\.OP_NO_SSL\*/ssl\.OP_NO_TLS\* options are deprecatedztornado.accessÚ
httpclientc                 S   s   t j| tdd�d�S )NF)Ú
allow_ipv6)Údefaults)r   Ú	configureÚdict)Úsr   r   r   Ú<lambda>¶   s    
ÿzmain.<locals>.<lambda>)ÚtypeÚdefaultÚcallbackÚ
httpserverÚresolverÚdebug_gcTzhA comma-separated list of gc module debug constants, e.g. DEBUG_STATS or DEBUG_COLLECTABLE,DEBUG_OBJECTSc                 S   s   t  ttjdd„ | D ƒƒ¡S )Nc                 s   s   � | ]}t t|ƒV  qd S r	   )ÚgetattrÚgc)r   Úvr   r   r   r   Ã   s   € z)main.<locals>.<lambda>.<locals>.<genexpr>)r[   Ú	set_debugr   ÚoperatorÚor_)Úvaluesr   r   r   rS   Â   s    ÿ)rT   ÚmultipleÚhelprV   zfail-if-logszTIf true, fail the tests if any log output is produced (unless captured by ExpectLog))rU   rb   c                 S   s   t  t j| ¡ d S r	   )ÚlocaleÚ	setlocaleÚLC_ALL)Úxr   r   r   Ú
set_localeÌ   s   zmain.<locals>.set_localerc   c                      s   t  ¡ jd  ˆ ¡S r3   )r9   Ú	getLoggerÚhandlersÚ	addFilterr   ©Úlog_counterr   r   rS   Ò   s    r   FÚwarningsÚ
testRunnerz?logged %d infos, %d warnings, %d errors, and %d bytes to stderrr7   r   )#rm   ÚfilterwarningsÚImportWarningÚUserWarningÚDeprecationWarningÚPendingDeprecationWarningÚBytesWarningÚsysÚversion_infoÚResourceWarningr9   rh   ÚsetLevelÚCRITICALr   Ústrr   rP   r   r2   r   r   r@   Útornado.testingr1   ÚtestingÚmainr4   r5   r6   rB   rF   r   Úfail_if_logsÚexit)rg   Úorig_stderrÚcounting_stderrÚtornador   r   rk   r   r}   q   sÖ   
ÿÿýÿýþþþþüú
ýûÿ÷ýûÿ÷r}   Ú__main__)Ú	functoolsr   r[   Úiorc   r9   r^   r#   ru   r
   rm   Útornado.httpclientr   Útornado.httpserverr   Útornado.netutilr   Útornado.optionsr   r   r   r   r   r1   ÚFilterr2   ÚIOBaser@   r}   r*   r   r   r   r   Ú<module>   s0    ' 
ÿ