o
    Zb^0                     @   s|   d 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 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.    )absolute_import)division)print_function)
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_infoZexpected_docstring_info r   DD:\Projects\ConvertPro\env\Lib\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 thats 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 thats 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_long3   s   
z%DocstringsTest.test_one_line_too_longc                 C   r   )NzrA one line docstring thats both a little too verbose and a little too long
    so it runs onto a second line.
    iA one line docstring thats 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 thats 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_whitespaceM   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.arg1Zarg1_descriptionnamedescriptionarg2Zarg2_descriptionr
   argsr   r   r   ArgInfor   r   r   r   r   test_google_format_args_onlyY   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"   Zarg_descriptionr   )r"   r#   r   r   r   r   !test_google_format_arg_named_argsj   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_returnsw   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-   r/   r0   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   r0   Description of arg1.r-   r    boolDescription of arg2.z'int -- description of the return value.zAttributeError, KeyError)r
   r   r"   r3   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(   r9   r*   r+   r,   r-   r/   r0   r1   z)bool True if successful, False otherwise.r2   r#   r   r   r   r   (test_numpy_format_typed_args_and_returns   s   
z7DocstringsTest.test_numpy_format_typed_args_and_returnsc              	   C   r5   )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(   r9   r*   r+   r,   r-   r/   r0   r6   r7   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  rD   rE   )r   r   Z_strip_blank_lines)r   linesZexpected_outputr   r   r   test_strip_blank_lines3  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   r0   zname, default : Worldr-   r    r+   zarg2, default:Nonearg3r;   r7   r#   r   r   r   r   test_numpy_colon_in_description9  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   r0   r:   r-   r    r;   r<   rH   zDescription of arg3.r!   )r   r   r   r$   	KwargInfor   r   r   r   r   %test_rst_format_typed_args_and_kwargsS  s    
	z4DocstringsTest.test_rst_format_typed_args_and_kwargsN)__name__
__module____qualname__r   r   r   r   r   r%   r&   r4   r8   r>   r?   r@   rA   rB   rC   rG   rI   rK   r   r   r   r   r      s&    
"
r   __main__N)__doc__Z
__future__r   r   r   firer   r   r   r$   rJ   ZBaseTestCaser   rL   mainr   r   r   r   <module>   s     O