
    &e                       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	m
Z
mZmZ d dlmZ d dlmZ d dlmZ d dlmZ d dlmZ d d	lmZ d d
lmZ d dlm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&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2m3Z3m4Z4m5Z5m6Z6m7Z7m8Z8m9Z9m:Z:m;Z;m<Z<m=Z=m>Z>m?Z?m@Z@mAZAmBZBmCZCmDZDmEZEmFZFmGZGmHZHmIZImJZJmKZKmLZLmMZMmNZN d dlOmPZP d dlQmRZR d dlSmTZT  ejU                    ZV eT              G d d          ZWdS )    )annotationsN)AnyCallableSequence)	MagicMock)parse)source_util)WidgetStates)Runtime)MemoryCacheStorageManager)MediaFileManager)MemoryMediaFileStorage)Secrets)SafeSessionState)SessionState)+BlockButtonCaption	ChatInputChatMessageCheckboxCodeColorPickerColumn	Dataframe	DateInputDividerElementListElementTreeError	ExceptionHeaderInfoJsonLatexMarkdownMetricMultiselectNodeNumberInputRadio	SelectboxSelectSliderSlider	SubheaderSuccessTabTableTextTextArea	TextInput	TimeInputTitleToastToggleWarning
WidgetListrepr_)LocalScriptRunner)HASHLIB_KWARGS)_fix_matplotlib_crashc                  ^   e Zd ZdZdndZedddod            Zedddpd            Zedddqd            Z	 	 drdsdZ	dddtdZ
edud            Zedud            Zedvd            Zedwd            Zedxd            Zedyd!            Zedzd#            Zed{d%            Zed|d'            Zed}d)            Zed~d+            Zedd-            Zedd/            Zedd1            Zedd3            Zedd5            Zedd7            Zedd9            Zedd;            Zedd=            Zedd?            Z eddA            Z!eddC            Z"eddE            Z#eddG            Z$eddI            Z%eddK            Z&eddM            Z'eddO            Z(eddQ            Z)eddS            Z*eddU            Z+eddW            Z,eddY            Z-edd[            Z.edd]            Z/edd_            Z0edda            Z1eddc            Z2ddeZ3df Z4ddiZ5ddlZ6ddmZ7dS )AppTesta#
  
    A simulated Streamlit app to check the correctness of displayed    elements and outputs.

    An instance of ``AppTest`` simulates a running Streamlit app. This class
    provides methods to set up, manipulate, and inspect the app contents via
    API instead of a browser UI. It can be used to write automated tests of an
    app in various scenarios. These can then be run using a tool like pytest.

    ``AppTest`` can be initialized by one of three class methods:

    * |st.testing.v1.AppTest.from_file|_ (recommended)
    * |st.testing.v1.AppTest.from_string|_
    * |st.testing.v1.AppTest.from_function|_

    Once initialized, Session State and widget values can be updated and the
    script can be run. Unlike an actual live-running Streamlit app, you need to
    call ``AppTest.run()`` explicitly to re-run the app after changing a widget
    value.

    ``AppTest`` enables developers to build tests on their app as-is, in the
    familiar python test format, without major refactoring or abstracting out
    logic to be tested separately from the UI. Tests can run quickly with very
    low overhead. A typical pattern is to build a suite of tests for an app
    that ensure consistent functionality as the app evolves, and run the tests
    locally and/or in a CI environment like Github Actions.

    .. note::
        ``AppTest`` only supports testing a single page of an app per
        instance. For multipage apps, each page will need to be tested
        separately. No methods exist to programatically switch pages within
        ``AppTest``.

    .. |st.testing.v1.AppTest.from_file| replace:: ``st.testing.v1.AppTest.from_file``
    .. _st.testing.v1.AppTest.from_file: #apptestfrom_file
    .. |st.testing.v1.AppTest.from_string| replace:: ``st.testing.v1.AppTest.from_string``
    .. _st.testing.v1.AppTest.from_string: #apptestfrom_string
    .. |st.testing.v1.AppTest.from_function| replace:: ``st.testing.v1.AppTest.from_function``
    .. _st.testing.v1.AppTest.from_function: #apptestfrom_function

    Attributes
    ----------
    secrets: dict[str, Any]
        Dictionary of secrets to be used the simulated app. Use dict-like
        syntax to set secret values for the simulated app.

    session_state: SafeSessionState
        Session State for the simulated app. SafeSessionState object supports
        read and write operations as usual for Streamlit apps.

    query_params: dict[str, Any]
        Dictionary of query parameters to be used by the simluated app. Use
        dict-like syntax to set ``query_params`` values for the simulated app.
    script_pathstrdefault_timeoutfloatc                   || _         || _        t          t                      d           | _        i | _        i | _        t                      }| |_        || _	        d S )Nc                     d S N rI       =lib/python3.11/site-packages/streamlit/testing/v1/app_test.py<lambda>z"AppTest.__init__.<locals>.<lambda>   s    d rJ   )
_script_pathrD   r   r   session_statequery_paramssecretsr   _runner_tree)selfrB   rD   trees       rK   __init__zAppTest.__init__   sT    '.-lnnllKK,.')}}


rJ      rD   scriptreturnc               @   t          j        t          |d          fi t          }|                                }t          j        t          j        |          }t          j
        |          }|                    |           t          t          |          |          S )a3  
        Create an instance of ``AppTest`` to simulate an app page defined        within a string.

        This is useful for testing short scripts that fit comfortably as an
        inline string in the test itself, without having to create a separate
        file for it. The script must be executable on its own and so must
        contain all necessary imports.

        Parameters
        ----------
        script: str
            The string contents of the script to be run.

        default_timeout: float
            Default time in seconds before a script run is timed out. Can be
            overridden for individual ``.run()`` calls.

        Returns
        -------
        AppTest
            A simulated Streamlit app for testing. The simulated app can be
            executed via ``.run()``.

        zutf-8rW   )hashlibmd5bytesr>   	hexdigestpathlibPathTMP_DIRnametextwrapdedent
write_textrA   rC   )clsrX   rD   hasherscript_namepathaligned_scripts          rK   from_stringzAppTest.from_string   s    6 U6733FF~FF&&((|GL+66!00'''s4yy/BBBBrJ   Callable[[], None]c               Z   t          j        |          \  }}t          j        d                    |                    }t          j        |          }|j        d         }||j        d         }t          j        d                    |                    }	| 	                    |	|          S )aS  
        Create an instance of ``AppTest`` to simulate an app page defined        within a function.

        This is similar to ``AppTest.from_string()``, but more convenient to
        write with IDE assistance. The script must be executable on its own and
        so must contain all necessary imports.

        Parameters
        ----------
        script: Callable
            A function whose body will be used as a script. Must be runnable
            in isolation, so it must include any necessary imports.

        default_timeout: float
            Default time in seconds before a script run is timed out. Can be
            overridden for individual ``.run()`` calls.

        Returns
        -------
        AppTest
            A simulated Streamlit app for testing. The simulated app can be
            executed via ``.run()``.

         r   NrW   )
inspectgetsourcelinesrc   rd   joinastr   bodylinenork   )
rf   rX   rD   source_lines_sourcemodulefn_def
body_linesrs   s
             rK   from_functionzAppTest.from_function   s    < "088a!6!6776""Q!&-//2
rwwz2233t_EEErJ   c               Z   t           j                            t          j        |                    r|}ngt          j                            t          j        d                    }t          j        |d         j                  }t          |j	        |z            }t          ||          S )a(  
        Create an instance of ``AppTest`` to simulate an app page defined        within a file.

        This option is most convenient for CI workflows and testing of
        published apps. The script must be executable on its own and so must
        contain all necessary imports.

        Parameters
        ----------
        script_path: str
            Path to a script file. The path should be absolute or relative to
            the file calling ``.from_file``.

        default_timeout: float
            Default time in seconds before a script run is timed out. Can be
            overridden for individual ``.run()`` calls.

        Returns
        -------
        AppTest
            A simulated Streamlit app for testing. The simulated app can be
            executed via ``.run()``.

        N   rW   )r_   r`   is_file	tracebackStackSummaryextract
walk_stackfilenamerC   parentrA   )rf   rB   rD   ri   stackfilepaths         rK   	from_filezAppTest.from_file   s    6 <[ 9 9:: 	6DD
 *2293G3M3MNNE|E!H$566Hx455Dt_====rJ   Nwidget_stateWidgetStates | Nonetimeoutfloat | Nonec                z   ddl }|| j        }t          t                    }t	          t          d                    |_        t                      |_        |t          _	        t          j        5  t          j        }dt          _        ddd           n# 1 swxY w Y   |j        }| j        r"t          g           }| j        |_        ||_        t!          | j        | j                  }|                    || j        |          | _        | | j        _        |j        d         d         j        }	t3          j        |	          | _        t          j        5  |t          _        ddd           n# 1 swxY w Y   | j        r1|j        j        t7          |j        j                  | _        ||_        dt          _	        | S )zRun the script, and parse the output messages for querying
        and interaction.

        Timeout is in seconds, or None to use the default timeout of the runner.
        r   N)specz/mock/mediaclient_state)	streamlitrD   r   r   r   r   media_file_mgrr   cache_storage_manager	_instancer	   _pages_cache_lock_cached_pagesrP   r   _secretsr=   rM   rN   runrO   rR   rQ   
event_dataquery_stringr   parse_qsdict)
rS   r   r   stmock_runtimesaved_cached_pagessaved_secretsnew_secretsscript_runnerr   s
             rK   _runzAppTest._run  s    	?*G !g...&6"=11'
 '
# .G-H-H*(* 	- 	-!,!:(,K%	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- "$< 	%!"++K#'<K $BJ)$*;T=OPP"&&|T5FPP
!
$/3NCP!N<88 * 	; 	;(:K%	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; < 	'z".#BJ$788&BJ s$   /BBBE,,E03E0r   c               8    | j                             |          S )a[  Run the script from the current state.

        This is equivalent to manually rerunning the app or the rerun that
        occurs upon user interaction. ``AppTest.run()`` must be manually called
        after updating a widget value as script reruns do not occur
        automatically as they do for live-running Streamlit apps.

        Parameters
        ----------
        timeout
            The maximum number of seconds to run the script. None means
            use the default timeout set for the instance of ``AppTest``.

        Returns
        -------
        AppTest
            self
        r   )rR   r   )rS   r   s     rK   r   zAppTest.runD  s    & z~~g~...rJ   r   c                    | j         j        S )aP  Sequence of elements within the main body of the app.

        Returns
        -------
        Block
            A container of elements. Block can be queried for elements in the
            same manner as ``AppTest``. For example, ``Block.checkbox`` will
            return all ``st.checkbox`` within the associated container.
        )rR   mainrS   s    rK   r   zAppTest.mainY  s     zrJ   c                    | j         j        S )aJ  Sequence of all elements within ``st.sidebar``.

        Returns
        -------
        Block
            A container of elements. Block can be queried for elements in the
            same manner as ``AppTest``. For example, ``Block.checkbox`` will
            return all ``st.checkbox`` within the associated container.
        )rR   sidebarr   s    rK   r   zAppTest.sidebarf  s     z!!rJ   WidgetList[Button]c                    | j         j        S )a  Sequence of all ``st.button`` and ``st.form_submit_button`` widgets.

        Returns
        -------
        WidgetList of Button
            Sequence of all ``st.button`` and ``st.form_submit_button``
            widgets. Individual widgets can be accessed from a WidgetList by
            index (order on the page) or key. For example, ``at.button[0]`` for
            the first widget or ``at.button(key="my_key")`` for a widget with a
            given key.
        )rR   buttonr   s    rK   r   zAppTest.buttons  s     z  rJ   ElementList[Caption]c                    | j         j        S )a  Sequence of all ``st.caption`` elements.

        Returns
        -------
        ElementList of Caption
            Sequence of all ``st.caption`` elements. Individual elements can be
            accessed from an ElementList by index (order on the page). For
            example, ``at.caption[0]`` for the first element. Caption is an
            extension of the Element class.
        )rR   captionr   s    rK   r   zAppTest.caption       z!!rJ   WidgetList[ChatInput]c                    | j         j        S )a  Sequence of all ``st.chat_input`` widgets.

        Returns
        -------
        WidgetList of ChatInput
            Sequence of all ``st.chat_input`` widgets. Individual widgets can
            be accessed from a WidgetList by index (order on the page) or key.
            For example, ``at.chat_input[0]`` for the first widget or
            ``at.chat_input(key="my_key")`` for a widget with a given key.
        )rR   
chat_inputr   s    rK   r   zAppTest.chat_input       z$$rJ   Sequence[ChatMessage]c                    | j         j        S )a  Sequence of all ``st.chat_message`` elements.

        Returns
        -------
        Sequence of ChatMessage
            Sequence of all ``st.chat_message`` elements. Individual elements can be
            accessed from an ElementList by index (order on the page). For
            example, ``at.chat_message[0]`` for the first element.  ChatMessage
            is an extension of the Block class.
        )rR   chat_messager   s    rK   r   zAppTest.chat_message       z&&rJ   WidgetList[Checkbox]c                    | j         j        S )a  Sequence of all ``st.checkbox`` widgets.

        Returns
        -------
        WidgetList of Checkbox
            Sequence of all ``st.checkbox`` widgets. Individual widgets can
            be accessed from a WidgetList by index (order on the page) or key.
            For example, ``at.checkbox[0]`` for the first widget or
            ``at.checkbox(key="my_key")`` for a widget with a given key.
        )rR   checkboxr   s    rK   r   zAppTest.checkbox       z""rJ   ElementList[Code]c                    | j         j        S )au  Sequence of all ``st.code`` elements.

        Returns
        -------
        ElementList of Code
            Sequence of all ``st.code`` elements. Individual elements can be
            accessed from an ElementList by index (order on the page). For
            example, ``at.code[0]`` for the first element. Code is an
            extension of the Element class.
        )rR   coder   s    rK   r   zAppTest.code       zrJ   WidgetList[ColorPicker]c                    | j         j        S )a  Sequence of all ``st.color_picker`` widgets.

        Returns
        -------
        WidgetList of ColorPicker
            Sequence of all ``st.color_picker`` widgets. Individual widgets can
            be accessed from a WidgetList by index (order on the page) or key.
            For example, ``at.color_picker[0]`` for the first widget or
            ``at.color_picker(key="my_key")`` for a widget with a given key.
        )rR   color_pickerr   s    rK   r   zAppTest.color_picker  r   rJ   Sequence[Column]c                    | j         j        S )a  Sequence of all columns within ``st.columns`` elements.

        Each column within a single ``st.columns`` will be returned as a
        separate Column in the Sequence.

        Returns
        -------
        Sequence of Column
            Sequence of all columns within ``st.columns`` elements. Individual
            columns can be accessed from an ElementList by index (order on the
            page). For example, ``at.columns[0]`` for the first column. Column
            is an extension of the Block class.
        )rR   columnsr   s    rK   r   zAppTest.columns  s     z!!rJ   ElementList[Dataframe]c                    | j         j        S )a  Sequence of all ``st.dataframe`` elements.

        Returns
        -------
        ElementList of Dataframe
            Sequence of all ``st.dataframe`` elements. Individual elements can be
            accessed from an ElementList by index (order on the page). For
            example, ``at.dataframe[0]`` for the first element. Dataframe is an
            extension of the Element class.
        )rR   	dataframer   s    rK   r   zAppTest.dataframe       z##rJ   WidgetList[DateInput]c                    | j         j        S )a  Sequence of all ``st.date_input`` widgets.

        Returns
        -------
        WidgetList of DateInput
            Sequence of all ``st.date_input`` widgets. Individual widgets can
            be accessed from a WidgetList by index (order on the page) or key.
            For example, ``at.date_input[0]`` for the first widget or
            ``at.date_input(key="my_key")`` for a widget with a given key.
        )rR   
date_inputr   s    rK   r   zAppTest.date_input  r   rJ   ElementList[Divider]c                    | j         j        S )a  Sequence of all ``st.divider`` elements.

        Returns
        -------
        ElementList of Divider
            Sequence of all ``st.divider`` elements. Individual elements can be
            accessed from an ElementList by index (order on the page). For
            example, ``at.divider[0]`` for the first element. Divider is an
            extension of the Element class.
        )rR   dividerr   s    rK   r   zAppTest.divider  r   rJ   ElementList[Error]c                    | j         j        S )az  Sequence of all ``st.error`` elements.

        Returns
        -------
        ElementList of Error
            Sequence of all ``st.error`` elements. Individual elements can be
            accessed from an ElementList by index (order on the page). For
            example, ``at.error[0]`` for the first element. Error is an
            extension of the Element class.
        )rR   errorr   s    rK   r   zAppTest.error       zrJ   ElementList[Exception]c                    | j         j        S )a  Sequence of all ``st.exception`` elements.

        Returns
        -------
        ElementList of Exception
            Sequence of all ``st.exception`` elements. Individual elements can be
            accessed from an ElementList by index (order on the page). For
            example, ``at.exception[0]`` for the first element. Exception is an
            extension of the Element class.
        )rR   	exceptionr   s    rK   r   zAppTest.exception  r   rJ   ElementList[Header]c                    | j         j        S )a  Sequence of all ``st.header`` elements.

        Returns
        -------
        ElementList of Header
            Sequence of all ``st.header`` elements. Individual elements can be
            accessed from an ElementList by index (order on the page). For
            example, ``at.header[0]`` for the first element. Header is an
            extension of the Element class.
        )rR   headerr   s    rK   r   zAppTest.header-       z  rJ   ElementList[Info]c                    | j         j        S )au  Sequence of all ``st.info`` elements.

        Returns
        -------
        ElementList of Info
            Sequence of all ``st.info`` elements. Individual elements can be
            accessed from an ElementList by index (order on the page). For
            example, ``at.info[0]`` for the first element. Info is an
            extension of the Element class.
        )rR   infor   s    rK   r   zAppTest.info;  r   rJ   ElementList[Json]c                    | j         j        S )au  Sequence of all ``st.json`` elements.

        Returns
        -------
        ElementList of Json
            Sequence of all ``st.json`` elements. Individual elements can be
            accessed from an ElementList by index (order on the page). For
            example, ``at.json[0]`` for the first element. Json is an
            extension of the Element class.
        )rR   jsonr   s    rK   r   zAppTest.jsonI  r   rJ   ElementList[Latex]c                    | j         j        S )az  Sequence of all ``st.latex`` elements.

        Returns
        -------
        ElementList of Latex
            Sequence of all ``st.latex`` elements. Individual elements can be
            accessed from an ElementList by index (order on the page). For
            example, ``at.latex[0]`` for the first element. Latex is an
            extension of the Element class.
        )rR   latexr   s    rK   r   zAppTest.latexW  r   rJ   ElementList[Markdown]c                    | j         j        S )a  Sequence of all ``st.markdown`` elements.

        Returns
        -------
        ElementList of Markdown
            Sequence of all ``st.markdown`` elements. Individual elements can be
            accessed from an ElementList by index (order on the page). For
            example, ``at.markdown[0]`` for the first element. Markdown is an
            extension of the Element class.
        )rR   markdownr   s    rK   r   zAppTest.markdowne  r   rJ   ElementList[Metric]c                    | j         j        S )a  Sequence of all ``st.metric`` elements.

        Returns
        -------
        ElementList of Metric
            Sequence of all ``st.metric`` elements. Individual elements can be
            accessed from an ElementList by index (order on the page). For
            example, ``at.metric[0]`` for the first element. Metric is an
            extension of the Element class.
        )rR   metricr   s    rK   r   zAppTest.metrics  r   rJ   WidgetList[Multiselect[Any]]c                    | j         j        S )a  Sequence of all ``st.multiselect`` widgets.

        Returns
        -------
        WidgetList of Multiselect
            Sequence of all ``st.multiselect`` widgets. Individual widgets can
            be accessed from a WidgetList by index (order on the page) or key.
            For example, ``at.multiselect[0]`` for the first widget or
            ``at.multiselect(key="my_key")`` for a widget with a given key.
        )rR   multiselectr   s    rK   r   zAppTest.multiselect  s     z%%rJ   WidgetList[NumberInput]c                    | j         j        S )a  Sequence of all ``st.number_input`` widgets.

        Returns
        -------
        WidgetList of NumberInput
            Sequence of all ``st.number_input`` widgets. Individual widgets can
            be accessed from a WidgetList by index (order on the page) or key.
            For example, ``at.number_input[0]`` for the first widget or
            ``at.number_input(key="my_key")`` for a widget with a given key.
        )rR   number_inputr   s    rK   r   zAppTest.number_input  r   rJ   WidgetList[Radio[Any]]c                    | j         j        S )a  Sequence of all ``st.radio`` widgets.

        Returns
        -------
        WidgetList of Radio
            Sequence of all ``st.radio`` widgets. Individual widgets can
            be accessed from a WidgetList by index (order on the page) or key.
            For example, ``at.radio[0]`` for the first widget or
            ``at.radio(key="my_key")`` for a widget with a given key.
        )rR   radior   s    rK   r   zAppTest.radio  r   rJ   WidgetList[SelectSlider[Any]]c                    | j         j        S )a  Sequence of all ``st.select_slider`` widgets.

        Returns
        -------
        WidgetList of SelectSlider
            Sequence of all ``st.select_slider`` widgets. Individual widgets can
            be accessed from a WidgetList by index (order on the page) or key.
            For example, ``at.select_slider[0]`` for the first widget or
            ``at.select_slider(key="my_key")`` for a widget with a given key.
        )rR   select_sliderr   s    rK   r   zAppTest.select_slider  s     z''rJ   WidgetList[Selectbox[Any]]c                    | j         j        S )a  Sequence of all ``st.selectbox`` widgets.

        Returns
        -------
        WidgetList of Selectbox
            Sequence of all ``st.selectbox`` widgets. Individual widgets can
            be accessed from a WidgetList by index (order on the page) or key.
            For example, ``at.selectbox[0]`` for the first widget or
            ``at.selectbox(key="my_key")`` for a widget with a given key.
        )rR   	selectboxr   s    rK   r   zAppTest.selectbox  r   rJ   WidgetList[Slider[Any]]c                    | j         j        S )a  Sequence of all ``st.slider`` widgets.

        Returns
        -------
        WidgetList of Slider
            Sequence of all ``st.slider`` widgets. Individual widgets can
            be accessed from a WidgetList by index (order on the page) or key.
            For example, ``at.slider[0]`` for the first widget or
            ``at.slider(key="my_key")`` for a widget with a given key.
        )rR   sliderr   s    rK   r   zAppTest.slider  r   rJ   ElementList[Subheader]c                    | j         j        S )a  Sequence of all ``st.subheader`` elements.

        Returns
        -------
        ElementList of Subheader
            Sequence of all ``st.subheader`` elements. Individual elements can be
            accessed from an ElementList by index (order on the page). For
            example, ``at.subheader[0]`` for the first element. Subheader is an
            extension of the Element class.
        )rR   	subheaderr   s    rK   r   zAppTest.subheader  r   rJ   ElementList[Success]c                    | j         j        S )a  Sequence of all ``st.success`` elements.

        Returns
        -------
        ElementList of Success
            Sequence of all ``st.success`` elements. Individual elements can be
            accessed from an ElementList by index (order on the page). For
            example, ``at.success[0]`` for the first element. Success is an
            extension of the Element class.
        )rR   successr   s    rK   r  zAppTest.success  r   rJ   ElementList[Table]c                    | j         j        S )az  Sequence of all ``st.table`` elements.

        Returns
        -------
        ElementList of Table
            Sequence of all ``st.table`` elements. Individual elements can be
            accessed from an ElementList by index (order on the page). For
            example, ``at.table[0]`` for the first element. Table is an
            extension of the Element class.
        )rR   tabler   s    rK   r  zAppTest.table  r   rJ   Sequence[Tab]c                    | j         j        S )a  Sequence of all tabs within ``st.tabs`` elements.

        Each tab within a single ``st.tabs`` will be returned as a separate Tab
        in the Sequence. Additionally, the tab labels are forwarded to each
        Tab element as a property. For example, ``st.tabs("A","B")`` will
        yield two Tab objects, with ``Tab.label`` returning "A" and "B",
        respectively.

        Returns
        -------
        Sequence of Tab
            Sequence of all tabs within ``st.tabs`` elements. Individual
            tabs can be accessed from an ElementList by index (order on the
            page). For example, ``at.tabs[0]`` for the first tab. Tab is an
            extension of the Block class.
        )rR   tabsr   s    rK   r  zAppTest.tabs  s    $ zrJ   ElementList[Text]c                    | j         j        S )au  Sequence of all ``st.text`` elements.

        Returns
        -------
        ElementList of Text
            Sequence of all ``st.text`` elements. Individual elements can be
            accessed from an ElementList by index (order on the page). For
            example, ``at.text[0]`` for the first element. Text is an
            extension of the Element class.
        )rR   textr   s    rK   r  zAppTest.text  r   rJ   WidgetList[TextArea]c                    | j         j        S )a  Sequence of all ``st.text_area`` widgets.

        Returns
        -------
        WidgetList of TextArea
            Sequence of all ``st.text_area`` widgets. Individual widgets can
            be accessed from a WidgetList by index (order on the page) or key.
            For example, ``at.text_area[0]`` for the first widget or
            ``at.text_area(key="my_key")`` for a widget with a given key.
        )rR   	text_arear   s    rK   r  zAppTest.text_area!  r   rJ   WidgetList[TextInput]c                    | j         j        S )a  Sequence of all ``st.text_input`` widgets.

        Returns
        -------
        WidgetList of TextInput
            Sequence of all ``st.text_input`` widgets. Individual widgets can
            be accessed from a WidgetList by index (order on the page) or key.
            For example, ``at.text_input[0]`` for the first widget or
            ``at.text_input(key="my_key")`` for a widget with a given key.
        )rR   
text_inputr   s    rK   r  zAppTest.text_input/  r   rJ   WidgetList[TimeInput]c                    | j         j        S )a  Sequence of all ``st.time_input`` widgets.

        Returns
        -------
        WidgetList of TimeInput
            Sequence of all ``st.time_input`` widgets. Individual widgets can
            be accessed from a WidgetList by index (order on the page) or key.
            For example, ``at.time_input[0]`` for the first widget or
            ``at.time_input(key="my_key")`` for a widget with a given key.
        )rR   
time_inputr   s    rK   r  zAppTest.time_input=  r   rJ   ElementList[Title]c                    | j         j        S )az  Sequence of all ``st.title`` elements.

        Returns
        -------
        ElementList of Title
            Sequence of all ``st.title`` elements. Individual elements can be
            accessed from an ElementList by index (order on the page). For
            example, ``at.title[0]`` for the first element. Title is an
            extension of the Element class.
        )rR   titler   s    rK   r  zAppTest.titleK  r   rJ   ElementList[Toast]c                    | j         j        S )az  Sequence of all ``st.toast`` elements.

        Returns
        -------
        ElementList of Toast
            Sequence of all ``st.toast`` elements. Individual elements can be
            accessed from an ElementList by index (order on the page). For
            example, ``at.toast[0]`` for the first element. Toast is an
            extension of the Element class.
        )rR   toastr   s    rK   r  zAppTest.toastY  r   rJ   WidgetList[Toggle]c                    | j         j        S )a  Sequence of all ``st.toggle`` widgets.

        Returns
        -------
        WidgetList of Toggle
            Sequence of all ``st.toggle`` widgets. Individual widgets can
            be accessed from a WidgetList by index (order on the page) or key.
            For example, ``at.toggle[0]`` for the first widget or
            ``at.toggle(key="my_key")`` for a widget with a given key.
        )rR   toggler   s    rK   r  zAppTest.toggleg  r   rJ   ElementList[Warning]c                    | j         j        S )a  Sequence of all ``st.warning`` elements.

        Returns
        -------
        ElementList of Warning
            Sequence of all ``st.warning`` elements. Individual elements can be
            accessed from an ElementList by index (order on the page). For
            example, ``at.warning[0]`` for the first element. Warning is an
            extension of the Element class.
        )rR   warningr   s    rK   r   zAppTest.warningu  r   rJ   intc                *    t          | j                  S rH   )lenrR   r   s    rK   __len__zAppTest.__len__  s    4:rJ   c              #  $   K   | j         E d {V  d S rH   rR   r   s    rK   __iter__zAppTest.__iter__  s&      :rJ   idxr)   c                    | j         |         S rH   r&  )rS   r(  s     rK   __getitem__zAppTest.__getitem__  s    z#rJ   element_typeSequence[Node]c                6    | j                             |          S )a  Get elements or widgets of the specified type.

        This method returns the collection of all elements or widgets of
        the specified type on the current page. Retrieve a specific element by
        using its index (order on page) or key lookup.

        Parameters
        ----------
        element_type: str
            An element attribute of ``AppTest``. For example, "button",
            "caption", or "chat_input".

        Returns
        -------
        Sequence of Elements
            Sequence of elements of the given type. Individual elements can
            be accessed from a Sequence by index (order on the page). When
            getting and ``element_type`` that is a widget, individual widgets
            can be accessed by key. For example, ``at.get("text")[0]`` for the
            first ``st.text`` element or ``at.get("slider")(key="my_key")`` for
            the ``st.slider`` widget with a given key.
        )rR   get)rS   r+  s     rK   r.  zAppTest.get  s    . z~~l+++rJ   c                     t          |           S rH   )r<   r   s    rK   __repr__zAppTest.__repr__  s    T{{rJ   )rB   rC   rD   rE   )rX   rC   rD   rE   rY   rA   )rX   rl   rD   rE   rY   rA   )rB   rC   rD   rE   rY   rA   )NN)r   r   r   r   rY   rA   )r   r   rY   rA   )rY   r   )rY   r   )rY   r   )rY   r   )rY   r   )rY   r   )rY   r   )rY   r   )rY   r   )rY   r   )rY   r   )rY   r   )rY   r   )rY   r   )rY   r   )rY   r   )rY   r   )rY   r   )rY   r   )rY   r   )rY   r   )rY   r   )rY   r   )rY   r   )rY   r   )rY   r   )rY   r   )rY   r   )rY   r  )rY   r  )rY   r	  )rY   r  )rY   r  )rY   r  )rY   r  )rY   r  )rY   r  )rY   r  )rY   r!  )r(  r!  rY   r)   )r+  rC   rY   r,  )rY   rC   )8__name__
__module____qualname____doc__rU   classmethodrk   r{   r   r   r   propertyr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r  r  r  r  r  r  r  r  r   r$  r'  r*  r.  r0  rI   rJ   rK   rA   rA   \   sM       5 5n	 	 	 	 BC  C  C  C  C  C [ CD EF#F #F #F #F #F [#FJ EF #> #> #> #> #> [#>N -1 $4 4 4 4 4l .2 / / / / / /* 
 
 
 X
 
" 
" 
" X
" ! ! ! X! " " " X" % % % X% ' ' ' X' # # # X#    X ' ' ' X' " " " X"  $ $ $ X$ % % % X% " " " X"       X  $ $ $ X$ ! ! ! X!    X    X       X  # # # X# ! ! ! X! & & & X& ' ' ' X'       X  ( ( ( X( $ $ $ X$ ! ! ! X! $ $ $ X$ " " " X"       X     X&    X $ $ $ X$ % % % X% % % % X%       X        X  ! ! ! X! " " " X"        , , , ,2     rJ   rA   )X
__future__r   rr   r[   ro   r_   tempfilerc   r   typingr   r   r   unittest.mockr   urllibr   r   r	    streamlit.proto.WidgetStates_pb2r
   streamlit.runtimer   5streamlit.runtime.caching.storage.dummy_cache_storager   $streamlit.runtime.media_file_managerr   +streamlit.runtime.memory_media_file_storager   streamlit.runtime.secretsr   *streamlit.runtime.state.safe_session_stater   %streamlit.runtime.state.session_stater   !streamlit.testing.v1.element_treer   r   r   r   r   r   r   r   r   r   r   r   r   r   r    r!   r"   r#   r$   r%   r&   r'   r(   r)   r*   r+   r,   r-   r.   r/   r0   r1   r2   r3   r4   r5   r6   r7   r8   r9   r:   r;   r<   (streamlit.testing.v1.local_script_runnerr=   streamlit.utilr>   streamlit.web.bootstrapr?   TemporaryDirectoryra   rA   rI   rJ   rK   <module>rI     s   # " " " " " 



          * * * * * * * * * * # # # # # #       ! ! ! ! ! ! 9 9 9 9 9 9 % % % % % %      B A A A A A N N N N N N - - - - - - G G G G G G > > > > > >, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,Z G F F F F F ) ) ) ) ) ) 9 9 9 9 9 9
%(
%
'
'     J J J J J J J J J JrJ   