
    i                     Z    U d Z ddlmZ ddlmZ dZeed<   	 ddZddZ	dd	Z
dd
ZddZy)z>Tests for parse_from_object function and attribute docstrings.    )patch)parse_from_object   module_attrNc                  .   ddl m}  t        |       }d|j                  v sJ t	        |j
                        dk(  sJ |j
                  d   j                  dk(  sJ |j
                  d   j                  dk(  sJ |j
                  d   j                  dk(  sJ y)	z5Test the parse of attribute docstrings from a module.r   )test_parse_from_objectr   r   r   intzDescription for module_attrN)	 r   r   short_descriptionlenparamsarg_name	type_namedescription)r   	docstrings     \C:\Projects\mas-dev\.venv\Lib\site-packages\docstring_parser/tests/test_parse_from_object.py%test_from_module_attribute_docstringsr      s    (!"89I)"="====y A%%%A''=888A((E111A**.KKKK    c                  0    G d d      } t        |       }|j                  dk(  sJ |j                  dk(  sJ |j                  dk(  sJ t	        |j
                        dk(  sJ |j
                  d   j                  dk(  sJ |j
                  d   j                  d	k(  sJ |j
                  d   j                  d
k(  sJ |j
                  d   j                  dk(  sJ |j
                  d   j                  dk(  sJ |j
                  d   j                  dk(  sJ y)z4Test the parse of attribute docstrings from a class.c                   ,    e Zd ZU dZeed<   	 dZeed<   y):test_from_class_attribute_docstrings.<locals>.StandardCasez3Short description
        Long description
        attr_oneFattr_twoN)__name__
__module____qualname____doc__str__annotations__r   bool r   r   StandardCaser      s    	 &$&r   r"   Short descriptionzLong descriptionz"Short description
Long description   r   r   r   Description for attr_oner   r   r    zDescription for attr_twoNr   r   long_descriptionr   r   r   r   r   )r"   r   s     r   $test_from_class_attribute_docstringsr(      s,   ' ' ",/I&&*====%%);;;;  $IIIIy A%%%A'':555A((E111A**.HHHHA'':555A((F222A**.HHHHr   c                  d    G d d      } t        |       }|j                  J |j                  J |j                  J t	        |j
                        dk(  sJ |j
                  d   j                  dk(  sJ |j
                  d   j                  J |j
                  d   j                  dk(  sJ y)z/Test the parse of untyped attribute docstrings.c                       e Zd ZdZy)Ftest_from_class_attribute_docstrings_without_type.<locals>.WithoutTypevalueN)r   r   r   r   r!   r   r   WithoutTyper+   6   s
    &r   r-   Nr   r   r   r%   r&   )r-   r   s     r   1test_from_class_attribute_docstrings_without_typer.   3   s    ' ' "+.I&&...%%---  (((y A%%%A'':555A((000A**.HHHHr   c                      G d d      } t        dt        d            5  t        |       }ddd       j                  dk(  sJ |j                  J |j
                  dk(  sJ t        |j                        dk(  sJ y# 1 sw Y   TxY w)	z3Test the parse of class when source is unavailable.c                       e Zd ZU dZeed<   y)5test_from_class_without_source.<locals>.WithoutSourcer#   r   N)r   r   r   r   r   r   r!   r   r   WithoutSourcer1   H   s    &r   r2   zinspect.getsourcezcould not get source code)side_effectNr#   r   )r   OSErrorr   r   r'   r   r   r   )r2   r   s     r   test_from_class_without_sourcer5   E   s    ' ' 
1L)M
 &m4	

 &&*====%%---  $7777y A%%%
 
s   B  B	c                     ddt         dt        fd} t        |       }|j                  dk(  sJ |j                  dk(  sJ t        |j                        dk(  sJ |j                  d   j                  dk(  sJ |j                  d   j                  J |j                  d   j                  dk(  sJ |j                  d	   j                  dk(  sJ |j                  d	   j                  J |j                  d	   j                  d
k(  sJ y)z'Test the parse of a function docstring.r$   param1param2c                     |  d| S )z~Short description
        Args:
            param1: Description for param1
            param2: Description for param2
         r!   )r7   r8   s     r   
a_functionz&test_from_function.<locals>.a_function\   s     6(##r   r#   r   NzDescription for param1r   zDescription for param2)r$   )	r   r	   r   r   r   r   r   r   r   )r;   r   s     r   test_from_functionr<   Y   s   $3 $ $ "*-I&&*====  $7777y A%%%A''8333A((000A**.FFFFA''8333A((000A**.FFFFr   )returnN)r   unittest.mockr   docstring_parserr   r   r	   r   r   r(   r.   r5   r<   r!   r   r   <module>r@      s8    D  .S  !
LI6I$&(Gr   