o
    հi                     @   sb   U d Z ddlmZ ddlmZ dZeed< 	 ddd	Zdd
dZ	dddZ
dddZdddZdS )z>Tests for parse_from_object function and attribute docstrings.    )patch)parse_from_object   module_attrreturnNc                  C   st   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s8J dS )	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   	docstring r   a/home/ubuntu/.local/lib/python3.10/site-packages/docstring_parser/tests/test_parse_from_object.py%test_from_module_attribute_docstrings   s   r   c                  C   s   G d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s3J |jd jd	ks=J |jd jd
ksGJ |jd jdksQJ |jd jdks[J |jd jdkseJ dS )z4Test the parse of attribute docstrings from a class.c                   @   s(   e Zd ZU dZeed< 	 dZeed< dS )z:test_from_class_attribute_docstrings.<locals>.StandardCasez3Short description
        Long description
        attr_oneFattr_twoN)__name__
__module____qualname____doc__str__annotations__r   boolr   r   r   r   StandardCase   s   
 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   r   r   r   $test_from_class_attribute_docstrings   s   
r#   c                  C   s   G dd d} t | }|jdu sJ |jdu sJ |jdu s J t|jdks)J |jd jdks3J |jd jdu s=J |jd jdksGJ dS )z/Test the parse of untyped attribute docstrings.c                   @   s   e Zd ZdZdS )zFtest_from_class_attribute_docstrings_without_type.<locals>.WithoutTypevalueN)r   r   r   r   r   r   r   r   WithoutType6   s    r%   Nr   r   r   r    r!   )r%   r   r   r   r   1test_from_class_attribute_docstrings_without_type3   s   r&   c                  C   s   G dd d} t dtdd t| }W d   n1 sw   Y  |jdks*J |jdu s1J |jdks8J t|jdksAJ dS )	z3Test the parse of class when source is unavailable.c                   @   s   e Zd ZU dZeed< dS )z5test_from_class_without_source.<locals>.WithoutSourcer   r   N)r   r   r   r   r   r   r   r   r   r   WithoutSourceH   s   
 r'   zinspect.getsourcezcould not get source code)side_effectNr   r   )r   OSErrorr   r
   r"   r   r   r   )r'   r   r   r   r   test_from_class_without_sourceE   s   
r*   c                  C   s   ddt dtfd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du s9J |jd jd	ksCJ |jd
 jdksMJ |jd
 jdu sWJ |jd
 jdksaJ dS )z'Test the parse of a function docstring.r   param1param2c                 S   s   |  d| S )z~Short description
        Args:
            param1: Description for param1
            param2: Description for param2
         r   )r+   r,   r   r   r   
a_function\   s   z&test_from_function.<locals>.a_functionr   r   NzDescription for param1r   zDescription for param2)r   )	r   r   r   r
   r   r   r   r   r   )r.   r   r   r   r   test_from_functionY   s   r/   )r   N)r   unittest.mockr   docstring_parserr   r   r   r   r   r#   r&   r*   r/   r   r   r   r   <module>   s    



