
    |h/                         d Z ddlmZ ddlmZ ej                  Zej
                  Zej                  Z G d dej                        Ze	dk(  r ej                          yy)z!Tests for fire docstrings module.    )
docstrings)	testutilsc                   x    e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Zy)DocstringsTestc                 n    d}t        j                  |      }t        d      }| j                  ||       y )NA simple one line docstring.summaryr   parseDocstringInfoassertEqualself	docstringdocstring_infoexpected_docstring_infos       S/var/www/html/test/engine/venv/lib/python3.12/site-packages/fire/docstrings_test.pytest_one_line_simplez#DocstringsTest.test_one_line_simple   s8    2I%%i0N+. 	,n=    c                 n    d}t        j                  |      }t        d      }| j                  ||       y )Nz(
      A simple one line docstring.
    r   r	   r   r   s       r   test_one_line_simple_whitespacez.DocstringsTest.test_one_line_simple_whitespace%   s<    I  %%i0N+. 	,n=r   c                 n    d}t        j                  |      }t        d      }| j                  ||       y )NzA one line docstring that is both a little too verbose and a little too long so it keeps going well beyond a reasonable length for a one-liner.
    zA one line docstring that is both a little too verbose and a little too long so it keeps going well beyond a reasonable length for a one-liner.r	   r   r   s       r   test_one_line_too_longz%DocstringsTest.test_one_line_too_long/   s>    I  %%i0N+
 	,n=r   c                 n    d}t        j                  |      }t        d      }| j                  ||       y )NztA one line docstring that is both a little too verbose and a little too long
    so it runs onto a second line.
    kA one line docstring that is both a little too verbose and a little too long so it runs onto a second line.r	   r   r   s       r   test_one_line_runs_overz&DocstringsTest.test_one_line_runs_over<   s>    I  %%i0N+; 	,n=r   c                 n    d}t        j                  |      }t        d      }| j                  ||       y )Nz}
      A one line docstring that is both a little too verbose and a little too long
      so it runs onto a second line.
    r   r	   r   r   s       r   "test_one_line_runs_over_whitespacez1DocstringsTest.test_one_line_runs_over_whitespaceI   s>    I  %%i0N+; 	,n=r   c                     d}t        j                  |      }t        dt        dd      t        dd      g      }| j	                  ||       y )	Nz_One line description.

    Args:
      arg1: arg1_description
      arg2: arg2_description
    zOne line description.arg1arg1_descriptionnamedescriptionarg2arg2_descriptionr
   argsr   r   r   ArgInfor   r   s       r   test_google_format_args_onlyz+DocstringsTest.test_google_format_args_onlyU   sW    I  %%i0N+'-?@-?@
 	,n=r   c                     d}t        j                  |      }t        t        dd      g      }| j	                  ||       y )Nz+
    Args:
      args: arg_description
    r)   arg_descriptionr#   )r)   r*   r   s       r   !test_google_format_arg_named_argsz0DocstringsTest.test_google_format_arg_named_argsf   sI    I  %%i0N+->?

 	,n=r   c           
          d}t        j                  |      }t        ddt        ddd      t        dd	d
      gd      }| j	                  ||       y )Na*  Docstring summary.

    This is a longer description of the docstring. It spans multiple lines, as
    is allowed.

    Args:
        param1 (int): The first parameter.
        param2 (str): The second parameter.

    Returns:
        bool: The return value. True for success, False otherwise.
    Docstring summary.VThis is a longer description of the docstring. It spans multiple lines, as
is allowed.param1intThe first parameter.r$   typer%   param2strThe second parameter.z:bool: The return value. True for success, False otherwise.r
   r%   r)   returnsr*   r   s       r   )test_google_format_typed_args_and_returnsz8DocstringsTest.test_google_format_typed_args_and_returnss   sl    I  %%i0N+$*  68 79
 M 	,n=r   c           
          d}t        j                  |      }t        ddt        ddd      t        dd	d
      g      }| j	                  ||       y )Na  Docstring summary.

    This is a longer description of the docstring. It spans multiple lines, as
    is allowed.

    Args:
        param1 (int): The first parameter.
        param2 (str): The second parameter. This has a lot of text, enough to
        cover two lines.
    r1   r2   r3   r4   r5   r6   r8   r9   HThe second parameter. This has a lot of text, enough to cover two lines.r
   r%   r)   r*   r   s       r   ,test_google_format_multiline_arg_descriptionz;DocstringsTest.test_google_format_multiline_arg_description   sh    	I  %%i0N+$*  68!=>
	 	,n=r   c           
          d}t        j                  |      }t        ddt        ddd      t        dd	d
      gdd      }| j	                  ||       y )NaD  Docstring summary.

    This is a longer description of the docstring. It spans across multiple
    lines.

    :param arg1: Description of arg1.
    :type arg1: str.
    :param arg2: Description of arg2.
    :type arg2: bool.
    :returns:  int -- description of the return value.
    :raises: AttributeError, KeyError
    r1   NThis is a longer description of the docstring. It spans across multiple
lines.r!   r9   Description of arg1.r6   r&   boolDescription of arg2.z'int -- description of the return value.zAttributeError, KeyError)r
   r%   r)   r<   raisesr*   r   s       r   &test_rst_format_typed_args_and_returnsz5DocstringsTest.test_rst_format_typed_args_and_returns   sn    I  %%i0N+$" e 68f 68
 :) 	,n=r   c           
          d}t        j                  |      }t        ddt        ddd      t        dd	d
      gd      }| j	                  ||       y )Na:  Docstring summary.

    This is a longer description of the docstring. It spans across multiple
    lines.

    Parameters
    ----------
    param1 : int
        The first parameter.
    param2 : str
        The second parameter.

    Returns
    -------
    bool
        True if successful, False otherwise.
    r1   rC   r3   r4   r5   r6   r8   r9   r:   z)bool True if successful, False otherwise.r;   r*   r   s       r   (test_numpy_format_typed_args_and_returnsz7DocstringsTest.test_numpy_format_typed_args_and_returns   sk    I"  %%i0N+$"  68 79
 < 	,n=r   c           
          d}t        j                  |      }t        ddt        ddd      t        dd	d
      g      }| j	                  ||       y )Na&  Docstring summary.

    This is a longer description of the docstring. It spans across multiple
    lines.

    Parameters
    ----------
    param1 : int
        The first parameter.
    param2 : str
        The second parameter. This has a lot of text, enough to cover two
        lines.
    r1   rC   r3   r4   r5   r6   r8   r9   r?   r@   r*   r   s       r   +test_numpy_format_multiline_arg_descriptionz:DocstringsTest.test_numpy_format_multiline_arg_description   sh    I  %%i0N+$"  68!=>
	 	,n=r   c                 p    d}t        j                  |      }t        dd      }| j                  ||       y )NzDocstring summary.

    This is the first section of a docstring description.

    This is the second section of a docstring description. This docstring
    description has just two sections.
    r1   zThis is the first section of a docstring description.

This is the second section of a docstring description. This docstring
description has just two sections.)r
   r%   r   r   s       r   test_multisection_docstringz*DocstringsTest.test_multisection_docstring  sA    I  %%i0N+$- 	,n=r   c                 j    d}t        j                  |      }| j                  d|j                         y )NztInspired by requests HTTPAdapter docstring.

    :param x: Simple param.

    Usage:

      >>> import requests
    z+Inspired by requests HTTPAdapter docstring.)r   r   r   r
   )r   r   r   s      r   )test_google_section_with_blank_first_linez8DocstringsTest.test_google_section_with_blank_first_line  s5    I  %%i0NB#++-r   c                 2    d}t        j                  |       y )NzDocstring summary.

    args: raises ::
    :
    pathological docstrings should not fail, and ideally should behave
    reasonably.
    )r   r   )r   r   s     r   test_ill_formed_docstringz(DocstringsTest.test_ill_formed_docstring%  s    I Yr   c                 \    g d}dg}| j                  |t        j                  |             y )N)     foo  rT   rU   )r   r   _strip_blank_lines)r   linesexpected_outputs      r   test_strip_blank_linesz%DocstringsTest.test_strip_blank_lines/  s)    %E kO_j&C&CE&JKr   c                     d}t        j                  |      }t        dd t        ddd      t        ddd	      t        d
dd       g      }| j	                  ||       y )Nz
     Greets name.

     Arguments
     ---------
     name : str
         name, default : World
     arg2 : int
         arg2, default:None
     arg3 : bool
     zGreets name.r$   r9   zname, default : Worldr6   r&   r4   zarg2, default:Nonearg3rE   r@   r*   r   s       r   test_numpy_colon_in_descriptionz.DocstringsTest.test_numpy_colon_in_description5  sn    
	I  %%i0N+e 79e 46f$?

 	,n=r   c           
          d}t        j                  |      }t        dt        ddd      t	        ddd	      t	        d
dd      g      }| j                  ||       y )NzDocstring summary.

    :param arg1: Description of arg1.
    :type arg1: str.
    :key arg2: Description of arg2.
    :type arg2: bool.
    :key arg3: Description of arg3.
    :type arg3: str.
    r1   r!   r9   rD   r6   r&   rE   rF   r[   zDescription of arg3.r(   )r   r   r   r+   	KwargInfor   r   s       r   %test_rst_format_typed_args_and_kwargsz4DocstringsTest.test_rst_format_typed_args_and_kwargsO  sn    I  %%i0N+$e 686"8:6"8:

 	,n=r   N)__name__
__module____qualname__r   r   r   r   r   r,   r/   r=   rA   rH   rJ   rL   rN   rP   rR   rY   r\   r_    r   r   r   r      s^    >>>>
>>">>8>4>: >D>:>&- L>4>r   r   __main__N)__doc__firer   r   r   r+   r^   BaseTestCaser   r`   mainrc   r   r   <module>ri      sc    (   ((


  	J>Y++ J>Z
 z).. r   