Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes15kdownloads
testing.cpython-313.pyc436 linesDownload Raw Back to __pycache__
1�

2��j�����SrSSKrSSKJr SSKrSSKrSSKrSSKrSSKrSSK	r	SSK3r4SSKrSSKrSSK
r
SSKJr SSKJrJr SSKJr SSKJrJr SSKJr SS	KJr SS5KJr SSKJr SSKJ r J!r! SS
K"J#r# SSK$r$SSK$J%r%J&r&J'r'J(r(J)r)J*r*J+r+J,r, SSK-J.r. \$R^(a\%\+\(\0\+\0\+\.4r1\r2S-S\3S\4S\%\6R\544Sjjr6S\74Sjr8"SS\Rr5r:"SS\:5r;"SS\;5r<\$RzSS.S\+\7S\'\'S\*\S44/\'S 44S!jj5r>\$RzS"\'S\*\S44S\'S 4S#j5r>S.S"\+\'S\*\S44S\+\7S\*\'S \'\'S\*\S44/\'S 444S$jjr>S\>l?"S%S&\R�5rAS'\RrS(\&S\&4S)jrBS*\&SS4S+jrC\DS,:Xa\C"5 gg)/a�Support classes for automated testing.7 8* `AsyncTestCase` and `AsyncHTTPTestCase`:  Subclasses of unittest.TestCase9  with additional support for testing asynchronous (`.IOLoop`-based) code.10 11* `ExpectLog`: Make test logs less spammy.12 13* `main()`: A simple test runner (wrapper around unittest.main()) with support14  for the tornado.autoreload module to rerun the tests when code changes.15�N)�	Generator)�gen)�AsyncHTTPClient�HTTPResponse)�16HTTPServer)�IOLoop�TimeoutError)�netutil)�AsyncIOMainLoop)�17Subprocess)�app_log)�raise_exc_info�basestring_type)�Application)�Tuple�Any�Callable�Type�Dict�Union�Optional�	Coroutine)�
TracebackTypeF�18reuse_port�address�returnc�~�[R"SU[RUS9SnUR	5SnX#4$)a)Binds a server socket to an available port on localhost.19 20Returns a tuple (socket, port).21 22.. versionchanged:: 4.423   Always binds to ``127.0.0.1`` without resolving the name24   ``localhost``.25 26.. versionchanged:: 6.227   Added optional ``address`` argument to28   override the default "127.0.0.1".29r)�familyr�)r30�bind_sockets�socket�AF_INET�getsockname)rr�sock�ports    �UD:\code\apps\devtools\python\user_packages\Python313\site-packages\tornado/testing.py�bind_unused_portr'1sF�����	�7�6�>�>�j���	�D�����a� �D��:��c��[RRS5nUb[U5$g![a gf=f)zqGet the global timeout setting for async tests.31 32Returns a float, the timeout in seconds.33 34.. versionadded:: 3.135�ASYNC_TEST_TIMEOUT�)�os�environ�get�float�36ValueError)�envs r&�get_async_test_timeoutr2GsG��
�*�*�.�.�-�37.�C�38��	���:��
���	���	�s�390�40=�=c�F^�\rSrSrSrSS\SS4U4SjjjrSU4SjjrSU4SjjrS\	4S	jr41S42\\S\S\
S\4S
jrSSjrSS\\R&S\\R&4U4SjjjrS\SS4SjrSS\S\SS4SjjrSS\\S\4S\\S\4SjjrSrU=r$)�
AsyncTestCase�Wa�`~unittest.TestCase` subclass for testing `.IOLoop`-based43asynchronous code.44 45The unittest framework is synchronous, so the test must be46complete by the time the test method returns. This means that47asynchronous code cannot be used in quite the same way as usual48and must be adapted to fit. To write your tests with coroutines,49decorate your test methods with `tornado.testing.gen_test` instead50of `tornado.gen.coroutine`.51 52This class also provides the (deprecated) `stop()` and `wait()`53methods for a more manual style of testing. The test method itself54must call ``self.wait()``, and asynchronous callbacks should call55``self.stop()`` to signal completion.56 57By default, a new `.IOLoop` is constructed for each test and is available58as ``self.io_loop``.  If the code being tested requires a59reused global `.IOLoop`, subclasses should override `get_new_ioloop` to return it,60although this is deprecated as of Tornado 6.3.61 62The `.IOLoop`'s ``start`` and ``stop`` methods should not be63called directly.  Instead, use `self.stop <stop>` and `self.wait64<wait>`.  Arguments passed to ``self.stop`` are returned from65``self.wait``.  It is possible to have multiple ``wait``/``stop``66cycles in the same test.67 68Example::69 70    # This test uses coroutine style.71    class MyTestCase(AsyncTestCase):72        @tornado.testing.gen_test73        def test_http_fetch(self):74            client = AsyncHTTPClient()75            response = yield client.fetch("http://www.tornadoweb.org")76            # Test contents of response77            self.assertIn("FriendFeed", response.body)78 79    # This test uses argument passing between self.stop and self.wait.80    class MyTestCase2(AsyncTestCase):81        def test_http_fetch(self):82            client = AsyncHTTPClient()83            client.fetch("http://www.tornadoweb.org/", self.stop)84            response = self.wait()85            # Test contents of response86            self.assertIn("FriendFeed", response.body)87�88methodNamerNc�x>�[TU]U5 SUlSUlSUlSUlSUlSUlg)NF)�super�__init__�_AsyncTestCase__stopped�_AsyncTestCase__running�_AsyncTestCase__failure�_AsyncTestCase__stop_args�_AsyncTestCase__timeout�_test_generator)�selfr6�	__class__s  �r&r9�AsyncTestCase.__init__�s>���
����$���������������� $��r(c��>�[RnSUs=::aS:dO SUs=::aS::a=O O:[U[R"55 [R89"SS[SS9 [TU]!5 [U5R[RLa[R"S	[5 UR5Ul
[R"URR 5 g)90N)��91r)rDrE�	)rD�r)rDrGr�ignorezThere is no current event loopztornado\..*)�message�category�modulezget_new_ioloop is deprecated)�sys�version_info�setup_with_context_manager�warnings�catch_warnings�filterwarnings�DeprecationWarningr8�setUp�type�get_new_ioloopr4�warn�io_loop�asyncio�set_event_loop�asyncio_loop)r@�py_verrAs  �r&rS�AsyncTestCase.setUp�s�����!�!���&�-�:�-�:��3U�:�3U�
'�t�X�-D�-D�-F�G��#�#��8�+�%�	
�	��
����:�$�$�M�,H�,H�H��M�M�8�:L�M��*�*�,������t�|�|�8�8�9r(c�>^�URRn[R"U5mTVs/sHo"R	5(aMUPM snmTHnUR5 M T(aDURR
U4Sj5up4U(aeUHnUR5 M [R"5 [R"S5 [UR[5(dURRSS9 [TU]A5 UR#5 gs snf![Ra M�f=f)Nc�0>�[R"T5$�N)rX�wait)�taskss�r&�<lambda>�(AsyncTestCase.tearDown.<locals>.<lambda>�s���'�,�,�u�:Mr(T)�all_fds)rWrZrX�	all_tasks�done�cancel�run_sync�result�CancelledErrorr�uninitializerY�92isinstance�_NON_OWNED_IOLOOPS�closer8�tearDown�_AsyncTestCase__rethrow)r@rZ�trf�pending�frarAs      @�r&ro�AsyncTestCase.tearDown�s���93�|�|�0�0���!�!�,�/��"�2�E�q�����E�2���A�
�H�H�J��� �L�L�1�1�2M�N�M�D���;�����H�H�J��	���!����t�$��$�,�,�(:�;�;�94
�L�L���t��,�
����95	
�����C3�� �-�-����s�D>�D>�(E�E�Ec��[SS9$)a�Returns the `.IOLoop` to use for this test.96 97By default, a new `.IOLoop` is created for each test.98Subclasses may override this method to return99`.IOLoop.current()` if it is not appropriate to use a new100`.IOLoop` in each tests (for example, if there are global101singletons using the default `.IOLoop`) or if a per-test event102loop is being provided by another system (such as103``pytest-asyncio``).104 105.. deprecated:: 6.3106   This method will be removed in Tornado 7.0.107F)�make_current)r�r@s r&rU�AsyncTestCase.get_new_ioloop�s���5�)�)r(�typ�value�tbc��URc108XU4UlO[R"SXU4S9 UR5 g)Nz%multiple unhandled exceptions in test)�exc_infoT)r<r
�error�stop�r@ryrzr{s    r&�_handle_exception�AsyncTestCase._handle_exception�s>���>�>�!�!�"�-�D�N��M�M�7�3�r�BR�
�	
�	�	��r(c�\�URbURnSUl[U5 ggr_)r<r)r@�failures  r&�	__rethrow�AsyncTestCase.__rethrow�s)���>�>�%��n�n�G�!�D�N��7�#�&r(ric�F>�[TU]U5nUR5 U$r_)r8�runrp)r@ri�retrAs   �r&r��AsyncTestCase.run�s$����g�k�&�!��109	
�����110r(�methodc��U"5n[U[5(d[R"U5(a[	S5eUb[SU-5eg)a8Run the given test method, raising an error if it returns non-None.111 112Failure to decorate asynchronous test methods with ``@gen_test`` can lead to tests113incorrectly passing.114 115Remove this override when Python 3.10 support is dropped. This check (in the form of a116DeprecationWarning) became a part of the standard library in 3.11.117 118Note that ``_callTestMethod`` is not documented as a public interface. However, it is119present in all supported versions of Python (3.8+), and if it goes away in the future that's120OK because we can just remove this override as noted above.121zVGenerator and coroutine test methods should be decorated with tornado.testing.gen_testNz)Return value from test method ignored: %r)rlr�inspect�iscoroutine�	TypeErrorr0)r@r�ris   r&�_callTestMethod�AsyncTestCase._callTestMethod�sX������f�i�(�(�G�,?�,?��,G�,G��;��
��
��H�6�Q�R�R� r(�_arg�kwargsc��Ub	U(aeU=(d UUlUR(a!URR5 SUlSUlg)aStops the `.IOLoop`, causing one pending (or future) call to `wait()`122to return.123 124Keyword arguments or a single positional argument passed to `stop()` are125saved and will be returned by `wait()`.126 127.. deprecated:: 5.1128 129   `stop` and `wait` are deprecated; use ``@gen_test`` instead.130NFT)r=r;rWrr:)r@r�r�s   r&r�AsyncTestCase.stopsB���|�6�)�)�!�>�T����>�>��L�L����"�D�N���r(�	condition.�timeoutc�L^^�Tc131[5mTR(d�T(aESUU4SjjnTRRTRR	5T-U5TlSTlTRR5 TRcUbU"5(aOM@TR132b,TRRTR1335 STlTR(deSTlTR5 TRnSTlU$)a8Runs the `.IOLoop` until stop is called or timeout has passed.134 135In the event of a timeout, an exception will be thrown. The136default timeout is 5 seconds; it may be overridden with a137``timeout`` keyword argument or globally with the138``ASYNC_TEST_TIMEOUT`` environment variable.139 140If ``condition`` is not ``None``, the `.IOLoop` will be restarted141after `stop()` until ``condition()`` returns ``True``.142 143.. versionchanged:: 3.1144   Added the ``ASYNC_TEST_TIMEOUT`` environment variable.145 146.. deprecated:: 5.1147 148   `stop` and `wait` are deprecated; use ``@gen_test`` instead.149Nc�>�TRST-5e![a [R"5TlOf=fTR5 g)Nz*Async operation timed out after %s seconds)�failureException�	ExceptionrLr}r<r)r@r�s��r&�timeout_func�(AsyncTestCase.wait.<locals>.timeout_funcCsJ���8�"�3�3�H�7�R����%�8�),������8���I�I�Ks��$>�>TF�rN)r2r:rW�add_timeout�timer>r;�startr<�remove_timeoutrpr=)r@r�r�r�ris` `  r&r`�AsyncTestCase.wait's����,�?�,�.�G��~�~�� � �"&���!9�!9��L�L�%�%�'�'�1�<�"����!%������"�"�$��>�>�-��1B�i�k�k��	�150�~�~�)����+�+�D�N�N�;�!%����~�~��~���������!�!������
r()�	__failure�	__running�__stop_args�	__stopped�	__timeoutr?rW)�runTestr�r_�NN)�__name__�151__module__�__qualname__�__firstlineno__�__doc__�strr9rSrorrUrr�r�boolr�rpr�unittest�152TestResultr�rr�rrr/r`�__static_attributes__�
__classcell__�rAs@r&r4r4Ws���-�^	$�3�	$�t�	$�	$�:�$*�X*��*� 153��	�?�154�+4�155�:G�156�	
�157�$�7;�	��x�2�2�3�	�	�(�%�%�	&�	�	�S�h�S�4�S�0���s��t��(48�#'�5��H�S�$�Y�/�0�5��%��5�158
�	5�5r(r4c	��^�\rSrSrSrSU4SjjrS\4SjrS\4Sjr	S\1594SjrSS\S	\
S160\S\4SjjrS\\\44SjrS\4S
jrS\4SjrS\S\4SjrSU4SjjrSrU=r$)�AsyncHTTPTestCasei_aA test case that starts up an HTTP server.161 162Subclasses must override `get_app()`, which returns the163`tornado.web.Application` (or other `.HTTPServer` callback) to be tested.164Tests will typically use the provided ``self.http_client`` to fetch165URLs from this server.166 167Example, assuming the "Hello, world" example from the user guide is in168``hello.py``::169 170    import hello171 172    class TestHelloApp(AsyncHTTPTestCase):173        def get_app(self):174            return hello.make_app()175 176        def test_homepage(self):177            response = self.fetch('/')178            self.assertEqual(response.code, 200)179            self.assertEqual(response.body, 'Hello, world')180 181That call to ``self.fetch()`` is equivalent to ::182 183    self.http_client.fetch(self.get_url('/'), self.stop)184    response = self.wait()185 186which illustrates how AsyncTestCase can turn an asynchronous operation,187like ``http_client.fetch()``, into a synchronous operation. If you need188to do other asynchronous operations in tests, you'll probably need to use189``stop()`` and ``wait()`` yourself.190rc��>�[TU]5 [5upX lUR	5UlUR
5UlUR5Ul	URRU/5 gr_)r8rSr'�_AsyncHTTPTestCase__port�get_http_client�http_client�get_app�_app�get_http_server�http_server�add_sockets)r@r$r%rAs   �r&rS�AsyncHTTPTestCase.setUp�s`���
��
��%�'�191�����/�/�1����L�L�N��	��/�/�1������$�$�d�V�,r(c��[5$r_)rrws r&r��!AsyncHTTPTestCase.get_http_client�s��� � r(c�J�[UR40UR5D6$r_)rr��get_httpserver_optionsrws r&r��!AsyncHTTPTestCase.get_http_server�s���$�)�)�E�t�'B�'B�'D�E�Er(c��[5e)zjShould be overridden by subclasses to return a192`tornado.web.Application` or other `.HTTPServer` callback.193)�NotImplementedErrorrws r&r��AsyncHTTPTestCase.get_app�s
��"�#�#r(�path�raise_errorr�c��^^^^�UR5RS5(aUmOTRU5mTRR	UUUU4Sj[5S9$)a�Convenience method to synchronously fetch a URL.194 195The given path will be appended to the local server's host and196port.  Any additional keyword arguments will be passed directly to197`.AsyncHTTPClient.fetch` (and so could be used to pass198``method="POST"``, ``body="..."``, etc).199 200If the path begins with http:// or https://, it will be treated as a201full URL and will be fetched as-is.202 203If ``raise_error`` is ``True``, a `tornado.httpclient.HTTPError` will204be raised if the response code is not 200. This is the same behavior205as the ``raise_error`` argument to `.AsyncHTTPClient.fetch`, but206the default is ``False`` here (it's ``True`` in `.AsyncHTTPClient`)207because tests often need to deal with non-200 response codes.208 209.. versionchanged:: 5.0210   Added support for absolute URLs.211 212.. versionchanged:: 5.1213 214   Added the ``raise_error`` argument.215 216.. deprecated:: 5.1217 218   This method currently turns any exception into an219   `.HTTPResponse` with status code 599. In Tornado 6.0,220   errors other than `tornado.httpclient.HTTPError` will be221   passed through, and ``raise_error=False`` will only222   suppress errors that would be raised due to non-200223   response codes.224 225)zhttp://zhttps://c�B>�TRR"T4ST0TD6$)Nr�)r��fetch)r�r�r@�urls����r&rb�)AsyncHTTPTestCase.fetch.<locals>.<lambda>�s ���D�$�$�*�*�3�R�K�R�6�Rr(�r�)�lower�226startswith�get_urlrWrhr2)r@r�r�r�r�s` ``@r&r��AsyncHTTPTestCase.fetch�sV���H�:�:�<�"�"�#:�;�;��C��,�,�t�$�C��|�|�$�$�R�*�,�%�227�	228r(c��0$)zWMay be overridden by subclasses to return additional229keyword arguments for the server.230�rws r&r��(AsyncHTTPTestCase.get_httpserver_options�s	���	r(c��UR$)zJReturns the port used by the server.231 232A new port is chosen for each test.233)r�rws r&�
get_http_port�AsyncHTTPTestCase.get_http_port�s��234�{�{�r(c��g)N�httpr�rws r&�get_protocol�AsyncHTTPTestCase.get_protocol�s��r(c�L�UR5SUR5U3$)z>Returns an absolute url for the given path on the test server.z
://127.0.0.1:)r�r�)r@r�s  r&r��AsyncHTTPTestCase.get_url�s+���#�#�%�&�m�D�4F�4F�4H�3I�$��P�Pr(c��>�URR5 URRURR[5S9 URR5 U?U?[TU])5 g)Nr�)r�rrWrh�close_all_connectionsr2r�rnr�r8ro)r@rAs �r&ro�AsyncHTTPTestCase.tearDown�sk�����������������2�2�<R�<T�	�	235�	
����� ����I�
���r()�__portr�r�r�r�)F)r�r�r�r�r�rSrr�rr�rr�r�r�rrr�rr��intr�r�r�ror�r�r�s@r&r�r�_s�����@-�!��!�F��F�$��$�.3�+236��+237�&*�+238�>A�+239�	�+240�Z��S�#�X����s���c��Q�C�Q�C�Q��r(r�c��\rSrSrSrS\4SjrS\\\	44Sjr241S\\\	44Sjr\S\\\	44Sj5r
S\4SjrS	rg242)�AsyncHTTPSTestCasei�zbA test case that starts an HTTPS server.243 244Interface is generally the same as `AsyncHTTPTestCase`.245rc�$�[S[SS9S9$)NTF)�
validate_cert)�force_instance�defaults)r�dictrws r&r��"AsyncHTTPSTestCase.get_http_client�s���d�T�PU�=V�W�Wr(c�0�[UR5S9$)N)�ssl_options)r��get_ssl_optionsrws r&r��)AsyncHTTPSTestCase.get_httpserver_options�s���� 4� 4� 6�7�7r(c�*�[R5$)zoMay be overridden by subclasses to select SSL options.246 247By default includes a self-signed testing certificate.248)r��default_ssl_optionsrws r&r��"AsyncHTTPSTestCase.get_ssl_options�s��249"�5�5�7�7r(c���[RR[5n[	[RRUSS5[RRUSS5S9$)N�testztest.crtztest.key)�certfile�keyfile)r,r��dirname�__file__r��join)�250module_dirs r&r��&AsyncHTTPSTestCase.default_ssl_options�sK���W�W�_�_�X�.�251���W�W�\�\�*�f�j�A��G�G�L�L��V�Z�@�252�	253r(c��g)N�httpsr�rws r&r��AsyncHTTPSTestCase.get_protocols��r(r�N)r�r�r�r�r�rr�rr�rr�r��staticmethodr�r�r�r�r(r&r�r��sl���254X��X�8��S�#�X��8�8��c�3�h��8��255256��c�3�h��257258��259260��c�r(r�r�r�.r�.Nc��gr_r�r�s r&�gen_testrs��	r(�funcc��gr_r�)rs r&rr
s��r(c�^�Tc261[5mS[S[[S44S[S4U4SjjnUbU"U5$U$)a�Testing equivalent of ``@gen.coroutine``, to be applied to test methods.262 263``@gen.coroutine`` cannot be used on tests because the `.IOLoop` is not264already running.  ``@gen_test`` should be applied to test methods265on subclasses of `AsyncTestCase`.266 267Example::268 269    class MyTest(AsyncHTTPTestCase):270        @gen_test271        def test_something(self):272            response = yield self.http_client.fetch(self.get_url('/'))273 274By default, ``@gen_test`` times out after 5 seconds. The timeout may be275overridden globally with the ``ASYNC_TEST_TIMEOUT`` environment variable,276or for each test with the ``timeout`` keyword argument::277 278    class MyTest(AsyncHTTPTestCase):279        @gen_test(timeout=10)280        def test_something_slow(self):281            response = yield self.http_client.fetch(self.get_url('/'))282 283Note that ``@gen_test`` is incompatible with `AsyncTestCase.stop`,284`AsyncTestCase.wait`, and `AsyncHTTPTestCase.fetch`. Use ``yield285self.http_client.fetch(self.get_url())`` as shown above instead.286 287.. versionadded:: 3.1288   The ``timeout`` argument and ``ASYNC_TEST_TIMEOUT`` environment289   variable.290 291.. versionchanged:: 4.0292   The wrapper now passes along ``*args, **kwargs`` so it can be used293   on functions with arguments.294 295rs.rrrc��>^^�[R"T5U4Sj5n[R"T5(aUmO[R296"U5m[R"T5UU4Sj5nU$)Nc�>�T"U/UQ70UD6n[U[5(d[R"U5(aX0lU$SUlU$r_)rlrr�r�r?)r@�argsr�rirss    �r&�
pre_coroutine�-gen_test.<locals>.wrap.<locals>.pre_coroutineHsR����t�-�d�-�f�-�F��&�)�,�,��0C�0C�F�0K�0K�'-�$��M�(,��$��Mr(c�>�URR[R"TU/UQ70UD6TS9$![aJnUR297b7[
UR298SS5(aUR299RU5 eSnAff=f)Nr��300cr_runningT)rWrh�	functools�partialr	r?�getattr�throw)r@rr��e�coror�s    ��r&�post_coroutine�.gen_test.<locals>.wrap.<locals>.post_coroutineXs����
��|�|�,�,��%�%�d�D�B�4�B�6�B�G�-���� �
��'�'�3���(�(�,��9�9��(�(�.�.�q�1�301��
�s�26�302B303�AB�B304)r�wrapsr��iscoroutinefunctionr�	coroutine)rsr
rrr�s`  @�r&�wrap�gen_test.<locals>.wrap?si���305����	�	�306�	��&�&�q�)�)� �D��=�=��/�D�	����	�	�307�	�.�r()r2rrr)rr�rs ` r&rrs[���T��(�*��1���e�I�{�$:�;�;�<�1��)�AT�1�f��308�D�z���r(c��\rSrSrSrSS\\R\4S\	S\309S\\SS4310S	jjr
S311\RS\3124SjrSSjrS
SS\\S\\SS4SjrSrg)�	ExpectLogi�a�Context manager to capture and suppress expected log output.313 314Useful to make tests of error conditions less noisy, while still315leaving unexpected log entries visible.  *Not thread safe.*316 317The attribute ``logged_stack`` is set to ``True`` if any exception318stack trace was logged.319 320Usage::321 322    with ExpectLog('tornado.application', "Uncaught exception"):323        error_response = self.fetch("/some_page")324 325.. versionchanged:: 4.3326   Added the ``logged_stack`` attribute.327N�logger�regex�required�levelrc���[U[5(a[R"U5nXl[328R"U5UlX0lSUl	SUl329SUlX@lSUl
g)a�Constructs an ExpectLog context manager.330 331:param logger: Logger object (or name of logger) to watch.  Pass an332    empty string to watch the root logger.333:param regex: Regular expression to match.  Any log entries on the334    specified logger that match this regex will be suppressed.335:param required: If true, an exception will be raised if the end of the336    ``with`` statement is reached without matching any log entries.337:param level: A constant from the ``logging`` module indicating the338    expected log level. If this parameter is provided, only log messages339    at this level will be considered to match. Additionally, the340    supplied ``logger`` will have its level adjusted if necessary (for341    the duration of the ``ExpectLog`` to enable the expected message.342 343.. versionchanged:: 6.1344   Added the ``level`` parameter.345 346.. deprecated:: 6.3347   In Tornado 7.0, only ``WARNING`` and higher logging levels will be348   matched by default. To match ``INFO`` and lower levels, the ``level``349   argument must be used. This is changing to minimize differences350   between ``tornado.testing.main`` (which enables ``INFO`` logs by351   default) and most other test runners (including those in IDEs)352   which have ``INFO`` logs disabled by default.353rFN)rlr�logging�	getLoggerr �re�compiler!r"�matched�deprecated_level_matched�logged_stackr#�354orig_level)r@r r!r"r#s     r&r9�ExpectLog.__init__�s_��@�f�o�.�.��&�&�v�.�F����Z�Z��&��355� �
����()��%�!����356���r(�recordc	�&�UR(aSUlUR5nURR	U5(a�UR357c3UR[R:aU=RS-
sl	UR358bfURUR359:waL[R"SU<S[R"UR3605<SUR<S35 gU=RS-
slgg)NTrzGot expected log message z at unexpected level (z vs �)F)r}r+�361getMessager!�matchr#�levelnor%�WARNINGr*r
�warning�getLevelName�	levelnamer))r@r.rIs   r&�filter�ExpectLog.filter�s����?�?� $�D���#�#�%���:�:���G�$�$��z�z�!�f�n�n�w���&F��-�-��2�-��z�z�%�&�.�.�D�J�J�*F������ 4� 4�T�Z�Z� @�&�BR�BR�T����L�L�A��L��r(c�&�URbhURURR5:a@URRUlURR	UR5 URRU5 U$r_)r#r �getEffectiveLevelr,�setLevel�	addFilterrws r&�	__enter__�ExpectLog.__enter__�sb���:�:�!�d�j�j�4�;�;�3P�3P�3R�&R�"�k�k�/�/�D�O��K�K� � ����,������d�#��r(ryzOptional[Type[BaseException]]rzr{c��URb%URRUR5 URRU5 U(d-UR(aUR362(d[
S5eU(dIUR(a7URUR363:�a[R"S[5 gggg)Nz did not get expected log messagez9ExpectLog matched at INFO or below without level argument)r,r r<�removeFilterr"r)r�r*rOrVrRr�s    r&�__exit__�ExpectLog.__exit__�s����?�?�&��K�K� � ����1���� � ��&��t�}�}�T�\�\��>�?�?���
�
��.�.�$�,�,�>��M�M�K�"�
�?��r()r*r#r+r r)r,r!r")TN)rr)r�r�r�r�r�rr%�Loggerrr�r�rr�r9�	LogRecordr8r>�
BaseExceptionrrBr�r�r(r&rr�s����*�#�*��g�n�n�o�5�6�*��*��	*�364��}�*�365�
*�X�W�.�.��4��,��
,���
�&��
�]�#�	�366367�r(r�testcase�cmc�b�UR5nURURSSS5 U$)a?Use a context manager to setUp a test case.368 369Example::370 371    def setUp(self):372        setup_with_context_manager(self, warnings.catch_warnings())373        warnings.filterwarnings("ignore", category=DeprecationWarning)374        # The catch_warnings context manager will be deactivated375        # automatically in tearDown.376 377N)r>�378addCleanuprB)rGrH�vals   r&rNrN�s,��
�,�,�.�C�������T�4��6��Jr(r�c�D�SSKJnJnJn U"S[SSS9 U"S[S9 U"S	[S9 U"S379[S9 U"S[S9 U"S[S9 [380RS/U"[381R5-nUR(d3[R"[R[R5 URbSUS'URbSUS'URbSUS382'URbSUS'URbSUS'[ S:Xa=[#U5S:Xa.[%S[383R&S9 [384R("S5 [#U5S:�a[*R,"SS
US.UD6 g
[*R,"SSUS.UD6 g
)a�A simple test runner.385 386This test runner is essentially equivalent to `unittest.main` from387the standard library, but adds support for Tornado-style option388parsing and log formatting. It is *not* necessary to use this389`main` function to run tests using `AsyncTestCase`; these tests390are self-contained and can run with any test runner.391 392The easiest way to run a test is via the command line::393 394    python -m tornado.testing tornado.test.web_test395 396See the standard library ``unittest`` module for ways in which397tests can be specified.398 399Projects with many tests may wish to define a test script like400``tornado/test/runtests.py``.  This script should define a method401``all()`` which returns a test suite and then call402`tornado.testing.main()`.  Note that even when a test script is403used, the ``all()`` test suite may be overridden by naming a404single test on the command line::405 406    # Runs all tests407    python -m tornado.test.runtests408    # Runs one test409    python -m tornado.test.runtests tornado.test.web_test410 411Additional keyword arguments passed through to ``unittest.main()``.412For example, use ``tornado.testing.main(verbosity=2)``413to show many test details as they are run.414See http://docs.python.org/library/unittest.html#unittest.main415for full argument list.416 417.. versionchanged:: 5.0418 419   This function produces no output of its own; only that produced420   by the `unittest` module (previously it would add a PASS or FAIL421   log message).422r)�define�options�parse_command_line�exception_on_interruptTz�If true (default), ctrl-c raises a KeyboardInterrupt exception.  This prints a stack trace but cannot interrupt certain operations.  If false, the process is more reliably killed, but does not print a stack trace.)rT�default�help�verbose)rT�quiet�failfast�catch�bufferN��	verbosity�423catchbreak�__main__rzNo tests specified)�file)rK�argv�all)�defaultTestr]r�)�tornado.optionsrMrNrOr�rLr]rP�signal�SIGINT�SIG_DFLrSrTrUrVrWr��len�print�stderr�exitr��main)r�rMrNrOr]s     r&rhrhs^��PD�C�424� �
��
8�425��9�4� �426�7���427�:�D�!�428�7���429�8�$���H�H�Q�K�=�-�c�h�h�7�7�D��)�)��
�
�f�m�m�V�^�^�4����"���{���}�}� ���{�����#�!��z���}�}� �#��|���~�~�!���x���:��#�d�)�q�.�
�"����4�������4�y�1�}��
�
�7�T��7��7��
�
�=�%�d�=�f�=r(r[)Fz	127.0.0.1r�)Er�rX�collections.abcrrr�r%r,r'rar!rLr�rO�tornador�tornado.httpclientrr�tornado.httpserverr�tornado.iolooprr	r430�tornado.platform.asyncior�tornado.processr�tornado.logr
�tornado.utilrr�tornado.webr�typingrrrrrrrr�typesr�
TYPE_CHECKINGrF�
_ExcInfoTuplermr�r�r�r'r/r2�TestCaser4r�r��overloadr�__test__�FilterrrNrhr�r�r(r&�<module>r{s���	��%����	�	�
�
�431����<�)�/��4�&��8�#�
�O�O�O��	������m�$�%�x�
�'>���@W�W��M�432%��.9����'*��433�6�=�=�#����,

��

� E�H�%�%�E�P@�
�@�F!�*�!�H���"&�	����	�
�x��U�9�k�#9�:�:�;�<�h�y�>Q�Q�R�	��	����	�8�C��y�+�'=�!>�>�?�	�H�Y�DW�	��	�434DH�#�h�435�8�C��y�+�'=�!>�>�?�436@�h�
�e�_�h���Y���h�s�E�)�[�"8�9�9�:�
;�X�i�=P�
P�Q�S��h�Z���n����n�d��):�):������"Y>�3�Y>�4�Y>�x�z���F�r(
codekingpro/portable-devtools · Team Ai