Team Ai
Datasetpublic

codekingpro/portable-devtools

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

2��j�'��j�SSKJr SSKrSSKrSSKJr SSKJr SSK	J	r	 SSK3Jr SSKJ
r
 SSKrSSKJr SS	KJr SS4KJr SSKJr SS
KJr SSKJr \R6(aSSKJr SSKJr SSKJ r  "SS\RBRD5r"Sq#SSjr$"SS\5r%"SS\5r&g)�)�annotationsN)�contextmanager)�	ExitStack)�copy)�
TracebackType)�urlsplit)�	CliRunner)�Result)�Client)�Request�)�5ScriptInfo)�SessionMixin)�WSGIEnvironment)�TestResponse)�Flaskc�d^�\rSrSrSrSSU4SjjjrSSjrSrU=r$)	�EnvironBuilder�auAn :class:`~werkzeug.test.EnvironBuilder`, that takes defaults from the6application.7 8:param app: The Flask application to configure the environment from.9:param path: URL path being requested.10:param base_url: Base URL where the app is being served, which11    ``path`` is relative to. If not given, built from12    :data:`PREFERRED_URL_SCHEME`, ``subdomain``,13    :data:`SERVER_NAME`, and :data:`APPLICATION_ROOT`.14:param subdomain: Subdomain name to append to :data:`SERVER_NAME`.15:param url_scheme: Scheme to use instead of16    :data:`PREFERRED_URL_SCHEME`.17:param json: If given, this is serialized as JSON and passed as18    ``data``. Also defaults ``content_type`` to19    ``application/json``.20:param args: other positional arguments passed to21    :class:`~werkzeug.test.EnvironBuilder`.22:param kwargs: other keyword arguments passed to23    :class:`~werkzeug.test.EnvironBuilder`.24c�B>�U(dU(dU(a!USL[U=(d U5:wdS5eUc�URRS5=(d SnURSn	U(aUSU3nUcURSn[U5n25U26R=(d USU27R28=(d USU	R
S53nU29RnU30R(aUS	U31R3nXl	[TU],"X#/UQ70UD6 g)32Nz8Cannot pass "subdomain" or "url_scheme" with "base_url".�SERVER_NAME�	localhost�APPLICATION_ROOT�.�PREFERRED_URL_SCHEMEz://�/�?)�bool�config�getr�scheme�netloc�lstrip�path�query�app�super�__init__)�selfr&r$�base_url�	subdomain�33url_scheme�args�kwargs�	http_host�app_root�url�	__class__s           ��SD:\code\apps\devtools\python\user_packages\Python313\site-packages\flask/testing.pyr(�EnvironBuilder.__init__1s����	�Z��D� �
�)�)�z�
*�=+�	34�
G�	35�+����36�37���}�5�D��I��z�z�"4�5�H��(�k��9�+�6�	��!� �Z�Z�(>�?�38��4�.�C��:�:�+��,�C��39�40�0G�i�/H��H�O�O�C�(�)�+�
��8�8�D��y�y���q�����,����
����9�$�9�&�9�c�P�URRR"U40UD6$)z�Serialize ``obj`` to a JSON-formatted string.41 42The serialization will be configured according to the config associated43with this EnvironBuilder's ``app``.44)r&�json�dumps)r)�objr.s   r3�45json_dumps�EnvironBuilder.json_dumpsXs"���x�x�}�}�"�"�3�1�&�1�1r5�r&)rNNN)r&rr$�strr*�46str | Noner+r>r,r>r-�t.Anyr.r?�return�None)r9r?r.r?r@r=)	�__name__�47__module__�__qualname__�__firstlineno__�__doc__r(r:�__static_attributes__�
__classcell__�r2s@r3rrsy����0�#� $�!%�
%:�
�%:��%:��	%:�48�%:��
%:��%:��%:�49�%:�%:�N2�2r5r�c�b�[(d[RRS5q[$)N�werkzeug)�_werkzeug_version�	importlib�metadata�version�r5r3�_get_werkzeug_versionrRds'����%�.�.�6�6�z�B���r5c��^�\rSrSr%SrS\S'SU4Sjjr\SSj5rSSjr	SSjr50S	S	S51.SU4SjjjrSSjrSS
jr
SrU=r$)�FlaskClient�ma�Works like a regular Werkzeug test client but has knowledge about52Flask's contexts to defer the cleanup of the request context until53the end of a ``with`` block. For general information about how to54use this class refer to :class:`werkzeug.test.Client`.55 56.. versionchanged:: 0.1257   `app.test_client()` includes preset default environment, which can be58   set after instantiation of the `app.test_client()` object in59   `client.environ_base`.60 61Basic usage is outlined in the :doc:`/testing` chapter.62r�applicationc�>�[TU]"U0UD6 SUl/Ul[	5UlSS[
53S.Ulg)NFz	127.0.0.1z	Werkzeug/)�REMOTE_ADDR�HTTP_USER_AGENT)r'r(�preserve_context�
_new_contextsr�_context_stackrR�environ_base)r)r-r.r2s   �r3r(�FlaskClient.__init__}sK���
���$�)�&�)� %���<>���'�k���&�!*�+@�+B�*C�D�63��r5c/�# �URc[S5eURnUR"U0UD6nUR	UR64R5 U URRX4R655nSSS5 Wc[S5eUv� UR5nURRU5(agU URRX5U5 SSS5 URUR66RRS5SUR67R UR"R%S55 g!,(df   N�=f!,(df   N�=f7f)a2When used in combination with a ``with`` statement this opens a68session transaction.  This can be used to modify the session that69the test client uses.  Once the ``with`` block is left the session is70stored back.71 72::73 74    with client.session_transaction() as session:75        session['value'] = 4276 77Internally this is implemented by going through a temporary test78request context and since session handling could depend on79request variables this function accepts the same arguments as80:meth:`~flask.Flask.test_request_context` which are directly81passed through.82Nz>Cookies are disabled. Create a client with 'use_cookies=True'.z'Session backend did not open a session.�:rz83Set-Cookie)�_cookies�	TypeErrorrV�test_request_context�_add_cookies_to_wsgi�request�environ�session_interface�open_session�RuntimeError�response_class�is_null_session�save_session�_update_cookies_from_response�host�	partitionr$�headers�getlist)r)r-r.r&�ctx�sess�resps       r3�session_transaction�FlaskClient.session_transaction�s6���(�=�=� ��P��
������&�&��7��7���!�!�#�+�+�"5�"5�6�
��(�(�5�5�c�;�;�G�D���<��H�I�I��84��!�!�#��� � �0�0��6�6��
��!�!�.�.�s�$�?��	
�*�*��K�K���&�&�s�+�A�.��K�K����L�L� � ��.�	85��S���S�s8�AF� &E�A
F�E0�0A/F�86E-�)F�087E>�:Fc�z�0UREUEnUR(aURRUS'U$)Nzwerkzeug.debug.preserve_context)r]rZr[�append)r)�other�outs   r3�
_copy_environ�FlaskClient._copy_environ�s<��,��"�"�,�e�,��� � �59�5G�5G�5N�5N�C�1�2��88r5c���URURS055US'[UR/UQ70UD6nUR	5UR5 $!UR5 f=f)Nr])r{r rrV�get_request�close)r)r-r.�builders    r3�_request_from_builder_args�&FlaskClient._request_from_builder_args�sb��"&�!3�!3�F�J�J�~�r�4R�!S��~�� ��!1�!1�C�D�C�F�C��	��&�&�(��M�M�O��G�M�M�O�s�A�A1F��buffered�follow_redirectsc�>�U(Ga2[US[RR[[8945(a�[US[RR5(aH[
US5nURUR=(d 05UlUR5nO�[US[5(a@[RUSURUR05S9R5nO@[
US5nURUR5UlOURX45nURR5 [ T	U]EUUUS9nURR$UlUR(HnURR+U5 M  UR(R-5 U$)Nr)r&r]r�)�90isinstancerL�testr�dict�BaseRequestrr{r]r~�from_environrVrfr�r\rr'�openr7�json_moduler[�
enter_context�clear)91r)r�r�r-r.r�re�response�cmr2s92         �r3r��FlaskClient.open�s�����J���G�h�m�m�2�2�D�+�F�93�94��$�q�'�8�=�=�#?�#?�@�@��t�A�w�-��'+�'9�'9�'�:N�:N�:T�RT�'U��$�!�-�-�/���D��G�T�*�*�(�5�5���G��!1�!1��@R�@R�SU�@V�6���+�-��95�t�A�w�-��"&�"4�"4�W�_�_�"E����5�5�d�C�G�96	
���!�!�#��7�<���-� �97��98 $�/�/�4�4����$�$�B����-�-�b�1�%�	
��� � �"��r5c�L�UR(a[S5eSUlU$)NzCannot nest client invocationsT)rZri�r)s r3�	__enter__�FlaskClient.__enter__�s$��� � ��?�@�@� $����r5c�F�SUlURR5 g)NF)rZr\r)r)�exc_type�	exc_value�tbs    r3�__exit__�FlaskClient.__exit__�s��!&������!�!�#r5)r\r[r]rZ)r-r?r.r?r@rA)r-r?r.r?r@zt.Iterator[SessionMixin])ryrr@r)r-ztuple[t.Any, ...]r.zdict[str, t.Any]r@r�)99r-r?r�rr�rr.r?r@r)r@rT)r�ztype | Noner�zBaseException | Noner�zTracebackType | Noner@rA)rBrCrDrErF�__annotations__r(rrur{r�r�r�r�rGrHrIs@r3rTrTms�������100��/101��/102�&+�/103�	!�/104��/105�b�	�%�	�/?�	�	�	��!&�	+��+��+��	+�106�+�107�
+�+�Z�$��$�(�$�
!�	$�108109�$�$r5rTc�T^�\rSrSrSrSU4SjjrSSU4SjjjrSrU=r$)	�FlaskCliRunneri	z�A :class:`~click.testing.CliRunner` for testing a Flask app's110CLI commands. Typically created using111:meth:`~flask.Flask.test_cli_runner`. See :ref:`testing-cli`.112c�2>�Xl[TU]"S0UD6 g)NrQ)r&r'r()r)r&r.r2s   �r3r(�FlaskCliRunner.__init__s�����
���"�6�"r5c�>^�UcTRRnSU;a[U4SjS9US'[TT]"X40UD6$)aInvokes a CLI command in an isolated environment. See113:meth:`CliRunner.invoke <click.testing.CliRunner.invoke>` for114full method documentation. See :ref:`testing-cli` for examples.115 116If the ``obj`` argument is not given, passes an instance of117:class:`~flask.cli.ScriptInfo` that knows how to load the Flask118app being tested.119 120:param cli: Command object to invoke. Default is the app's121    :attr:`~flask.app.Flask.cli` group.122:param args: List of strings to invoke the command with.123 124:return: a :class:`~click.testing.Result` object.125r9c�>�TR$)Nr<r�s�r3�<lambda>�'FlaskCliRunner.invoke.<locals>.<lambda>(s	���$�(�(r5)�126create_app)r&�clirr'�invoke)r)r�r-r.r2s`   �r3r��FlaskCliRunner.invokesB���"�;��(�(�,�,�C����&�2B�C�F�5�M��w�~�c�2�6�2�2r5r<)r&rr.r?r@rA)NN)r�r?r-r?r.r?r@r127)	rBrCrDrErFr(r�rGrHrIs@r3r�r�	s<����128#�12904�3��3�',�3�?D�3�	�3�3r5r�)r@r=)'�130__future__r�importlib.metadatarN�typing�t�131contextlibrrr�typesr�urllib.parser�
werkzeug.testrL�
click.testingr	r132r�werkzeug.wrappersrr�r�r�sessionsr�
TYPE_CHECKING�_typeshed.wsgirrr&rr�rrMrRrTr�rQr5r3�<module>r�s���"���%� ���!��#� � �4��"��?�?�.�*��C2�X�]�]�1�1�C2�L���Y$�&�Y$�x!3�Y�!3r5
codekingpro/portable-devtools · Team Ai