U
    +c^0                     @   sx   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rte  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   8/tmp/pip-unpacked-wheel-1xt1w7un/fire/docstrings_test.pytest_one_line_simple!   s    
z#DocstringsTest.test_one_line_simplec                 C   s(   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   s(   d}t |}tdd}| || d S )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   s(   d}t |}tdd}| || d S )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   s(   d}t |}tdd}| || d S )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   sF   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   sD   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-   r.   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   r.   Description of arg1.r+   r   boolDescription of arg2.z'int -- description of the return value.zAttributeError, KeyError)r
   r   r!   r1   Zraisesr"   r   r   r   r   &test_rst_format_typed_args_and_returns   s     
z5DocstringsTest.test_rst_format_typed_args_and_returnsc              	   C   sF   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 across multiple
    lines.

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

    Returns
    -------
    bool
        True if successful, False otherwise.
    r&   r6   r(   r)   r*   r+   r-   r.   r/   z)bool True if successful, False otherwise.r0   r"   r   r   r   r   (test_numpy_format_typed_args_and_returns   s    
z7DocstringsTest.test_numpy_format_typed_args_and_returnsc              	   C   sD   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 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&   r6   r(   r)   r*   r+   r-   r.   r3   r4   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&   dddg}dg}|  |t| d S )Nz   z  foo  )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   r.   zname, default : Worldr+   r   r)   zarg2, default:Nonearg3r8   r4   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   r.   r7   r+   r   r8   r9   rB   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%   r2   r5   r:   r;   r<   r=   r>   r?   rA   rC   rE   r   r   r   r   r      s$   
"
r   __main__N)__doc__
__future__r   r   r   Zfirer   r   r   r#   rD   ZBaseTestCaser   rF   mainr   r   r   r   <module>   s     O