o
    Ďi/                     @   sX   d Z ddlmZ ddlmZ ejZejZejZG dd dejZe	dkr*e
  dS dS )z!Tests for fire docstrings module.    )
docstrings)	testutilsc                   @   s   e Zd Zdd Zdd Zdd Zdd Zd	d
 Zdd Zdd Z	dd Z
dd Zdd Zdd Zdd Zdd Zdd Zdd Zdd  Zd!d" Zd#d$ Zd%S )&DocstringsTestc                 C   s(   d}t |}tdd}| || d S )NA simple one line docstring.summaryr   parseDocstringInfoassertEqualself	docstringdocstring_infoexpected_docstring_info r   P/home/jeff/fluffinator/venv/lib/python3.10/site-packages/fire/docstrings_test.pytest_one_line_simple   s   
z#DocstringsTest.test_one_line_simplec                 C   (   d}t |}tdd}| || d S )Nz(
      A simple one line docstring.
    r   r   r   r   r   r   r   test_one_line_simple_whitespace%   s   
z.DocstringsTest.test_one_line_simple_whitespacec                 C   r   )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   r   r   r   test_one_line_too_long/   s   
z%DocstringsTest.test_one_line_too_longc                 C   r   )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   r   r   r   test_one_line_runs_over<   s   
z&DocstringsTest.test_one_line_runs_overc                 C   r   )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   r   r   r   "test_one_line_runs_over_whitespaceI   s   
z1DocstringsTest.test_one_line_runs_over_whitespacec                 C   s>   d}t |}tdtdddtdddgd}| || d S )	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   r   r   r   test_google_format_args_onlyU   s   


z+DocstringsTest.test_google_format_args_onlyc                 C   s2   d}t |}ttdddgd}| || d S )Nz+
    Args:
      args: arg_description
    r"   arg_descriptionr   )r"   r#   r   r   r   r   !test_google_format_arg_named_argsf   s   

z0DocstringsTest.test_google_format_arg_named_argsc              	   C   F   d}t |}tddtddddtdd	d
dgdd}| || d S )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   r   r   r   )test_google_format_typed_args_and_returnss   s   
z8DocstringsTest.test_google_format_typed_args_and_returnsc              	   C   D   d}t |}tddtddddtdd	d
dgd}| || d S )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.
    r)   r*   r+   r,   r-   r.   r0   r1   HThe second parameter. This has a lot of text, enough to cover two lines.r   r   r"   r#   r   r   r   r   ,test_google_format_multiline_arg_description   s   

z;DocstringsTest.test_google_format_multiline_arg_descriptionc              	   C   sH   d}t |}tddtddddtdd	d
dgddd}| || d S )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
    r)   NThis is a longer description of the docstring. It spans across multiple
lines.r   r1   Description of arg1.r.   r   boolDescription of arg2.z'int -- description of the return value.zAttributeError, KeyError)r   r   r"   r4   raisesr#   r   r   r   r   &test_rst_format_typed_args_and_returns   s    
z5DocstringsTest.test_rst_format_typed_args_and_returnsc              	   C   r(   )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.
    r)   r:   r+   r,   r-   r.   r0   r1   r2   z)bool True if successful, False otherwise.r3   r#   r   r   r   r   (test_numpy_format_typed_args_and_returns   s   
z7DocstringsTest.test_numpy_format_typed_args_and_returnsc              	   C   r6   )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.
    r)   r:   r+   r,   r-   r.   r0   r1   r7   r8   r#   r   r   r   r   +test_numpy_format_multiline_arg_description   s   
z:DocstringsTest.test_numpy_format_multiline_arg_descriptionc                 C   s*   d}t |}tddd}| || d S )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.
    r)   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   r   r   r   test_multisection_docstring  s   
z*DocstringsTest.test_multisection_docstringc                 C   s    d}t |}| d|j d S )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   r   r   r   )test_google_section_with_blank_first_line  s
   
z8DocstringsTest.test_google_section_with_blank_first_linec                 C   s   d}t | d S )NzDocstring summary.

    args: raises ::
    :
    pathological docstrings should not fail, and ideally should behave
    reasonably.
    )r   r	   )r   r   r   r   r   test_ill_formed_docstring%  s   z(DocstringsTest.test_ill_formed_docstringc                 C   s$   g d}dg}|  |t| d S )N)     foo  rE   rF   )r   r   _strip_blank_lines)r   linesexpected_outputr   r   r   test_strip_blank_lines/  s   z%DocstringsTest.test_strip_blank_linesc              
   C   sP   d}t |}tdd tddddtddd	dtd
dd dgd}| || d S )Nz
     Greets name.

     Arguments
     ---------
     name : str
         name, default : World
     arg2 : int
         arg2, default:None
     arg3 : bool
     zGreets name.r   r1   zname, default : Worldr.   r   r,   zarg2, default:Nonearg3r<   r8   r#   r   r   r   r   test_numpy_colon_in_description5  s   
z.DocstringsTest.test_numpy_colon_in_descriptionc              	   C   sN   d}t |}tdtddddtddd	dtd
dddgd}| || d S )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.
    r)   r   r1   r;   r.   r   r<   r=   rK   zDescription of arg3.r!   )r   r	   r
   r$   	KwargInfor   r   r   r   r   %test_rst_format_typed_args_and_kwargsO  s    
	z4DocstringsTest.test_rst_format_typed_args_and_kwargsN)__name__
__module____qualname__r   r   r   r   r   r%   r'   r5   r9   r?   r@   rA   rB   rC   rD   rJ   rL   rN   r   r   r   r   r      s&    
"
r   __main__N)__doc__firer   r   r
   r$   rM   BaseTestCaser   rO   mainr   r   r   r   <module>   s     O