o
    b/                     @   sT   d Z ddlmZmZmZ ddlZddlmZmZm	Z	 ddl
mZ G dd deZdS )zqUnit tests for the yield documentation checking in the
`DocstringChecker` in :mod:`pylint.extensions.check_docs`
    )divisionprint_functionabsolute_importN)CheckerTestCaseMessage
set_config)DocstringParameterCheckerc                   @   s   e Zd ZdZeZdd Zedd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*d+ Zd,d- Zd.d/ Zd0d1 Zd2d3 Zd4d5 Zd6d7 Z d8S )9TestDocstringCheckerYieldz'Tests for pylint_plugin.RaiseDocCheckerc                 C   D   t d}|   | j| W d    d S 1 sw   Y  d S )Nz?
        def my_func(self):
            yield False #@
        astroidextract_nodeassertNoMessagescheckervisit_yieldself
yield_node r   l/var/www/secure340b-portal/env/lib/python3.10/site-packages/pylint/test/extensions/test_check_yields_docs.pytest_ignores_no_docstring   s   

"z3TestDocstringCheckerYield.test_ignores_no_docstringF)Zaccept_no_yields_docc                 C   b   t d}|jd }| td|dtd|d | j| W d    d S 1 s*w   Y  d S )Nz<
        def my_func(self):
            yield False
        r   missing-yield-docZmsg_idnodemissing-yield-type-docr   r   bodyassertAddsMessagesr   r   r   r   r   r   r   r   r   test_warns_no_docstring    s   



"z1TestDocstringCheckerYield.test_warns_no_docstringc                 C   r
   )Nzf
        def my_func(self):
            """This is a docstring."""
            yield False #@
        r   r   r   r   r   test_ignores_unknown_style,   s   

"z4TestDocstringCheckerYield.test_ignores_unknown_stylec                 C   X   t d}|jd }| td|d | j| W d    d S 1 s%w   Y  d S )Nz
        def my_func(self):
            """This is a docstring.

            :returns: Always False
            """
            yield False
        r   r   r   r   r   r   r   r   test_warn_partial_sphinx_yields5      


"z9TestDocstringCheckerYield.test_warn_partial_sphinx_yieldsc                 C   r"   )Nz
        def my_func(self):
            """This is a docstring.

            :rtype: bool
            """
            yield False
        r   r   r   r   r   r   r   r   $test_warn_partial_sphinx_yields_typeC   r$   z>TestDocstringCheckerYield.test_warn_partial_sphinx_yields_typec                 C   r   )Nz
        def my_func(self, doc_type):
            """This is a docstring.

            :param doc_type: Sphinx
            :type doc_type: str
            """
            yield False
        r   r   r   r   r   r   r   r   r   test_warn_missing_sphinx_yieldsQ      

	

"z9TestDocstringCheckerYield.test_warn_missing_sphinx_yieldsc                 C   r"   )Nz
        def my_func(self):
            """This is a docstring.

            Yields:
                Always False
            """
            yield False
        r   r   r   r   r   r   r   r   test_warn_partial_google_yieldsa      

	
"z9TestDocstringCheckerYield.test_warn_partial_google_yieldsc                 C   r"   )Nz
        def my_func(self):
            """This is a docstring.

            Yields:
                bool:
            """
            yield False
        r   r   r   r   r   r   r   r   $test_warn_partial_google_yields_typep   r)   z>TestDocstringCheckerYield.test_warn_partial_google_yields_typec                 C   r   )Nz
        def my_func(self, doc_type):
            """This is a docstring.

            Parameters:
                doc_type (str): Google
            """
            yield False
        r   r   r   r   r   r   r   r   r   test_warn_missing_google_yields   r'   z9TestDocstringCheckerYield.test_warn_missing_google_yieldsc                 C   r   )Nz
        def my_func(self, doc_type):
            """This is a docstring.

            Arguments
            ---------
            doc_type : str
                Numpy
            """
            yield False
        r   r   r   r   r   r   r   r   r   test_warn_missing_numpy_yields   s   



"z8TestDocstringCheckerYield.test_warn_missing_numpy_yieldsc                 C   r
   )Nz
        def my_func(self):
            """This is a docstring.

            :return: Always False
            :rtype: bool
            """
            yield False #@
        r   r   r   r   r   test_find_sphinx_yields      

	"z1TestDocstringCheckerYield.test_find_sphinx_yieldsc                 C   r
   )Nz
        def my_func(self):
            """This is a docstring.

            Yields:
                bool: Always False
            """
            yield False #@
        r   r   r   r   r   test_find_google_yields   r.   z1TestDocstringCheckerYield.test_find_google_yieldsc                 C   r
   )Nz
        def my_func(self):
            """This is a docstring.

            Yields
            -------
            bool
                Always False
            """
            yield False #@
        r   r   r   r   r   test_find_numpy_yields      

"z0TestDocstringCheckerYield.test_find_numpy_yieldsc                 C   r
   )Nz
        def my_func(self):
            """This is a docstring.

            :returns: An object
            :rtype: :class:`mymodule.Class`
            """
            yield mymodule.Class() #@
        r   r   r   r   r   $test_finds_sphinx_yield_custom_class   r.   z>TestDocstringCheckerYield.test_finds_sphinx_yield_custom_classc                 C   r
   )Nz
        def my_func(self):
            """This is a docstring.

            Yields:
                mymodule.Class: An object
            """
            yield mymodule.Class() #@
        r   r   r   r   r   $test_finds_google_yield_custom_class   r.   z>TestDocstringCheckerYield.test_finds_google_yield_custom_classc                 C   r
   )Nz
        def my_func(self):
            """This is a docstring.

            Yields
            -------
                mymodule.Class
                    An object
            """
            yield mymodule.Class() #@
        r   r   r   r   r   #test_finds_numpy_yield_custom_class   r1   z=TestDocstringCheckerYield.test_finds_numpy_yield_custom_classc                 C   r
   )Nz
        def my_func(self):
            """This is a docstring.

            :returns: An object
            :rtype: list(:class:`mymodule.Class`)
            """
            yield [mymodule.Class()] #@
        r   r   r   r   r   ,test_finds_sphinx_yield_list_of_custom_class   r.   zFTestDocstringCheckerYield.test_finds_sphinx_yield_list_of_custom_classc                 C   r
   )Nz
        def my_func(self):
            """This is a docstring.

            Yields:
                list(:class:`mymodule.Class`): An object
            """
            yield [mymodule.Class()] #@
        r   r   r   r   r   ,test_finds_google_yield_list_of_custom_class   r.   zFTestDocstringCheckerYield.test_finds_google_yield_list_of_custom_classc                 C   r
   )Nz
        def my_func(self):
            """This is a docstring.

            Yields
            -------
                list(:class:`mymodule.Class`)
                    An object
            """
            yield [mymodule.Class()] #@
        r   r   r   r   r   +test_finds_numpy_yield_list_of_custom_class  r1   zETestDocstringCheckerYield.test_finds_numpy_yield_list_of_custom_classc                 C   r"   )Nz
        def my_func(self):
            """This is a docstring.

            :rtype: list(:class:`mymodule.Class`)
            """
            yield [mymodule.Class()]
        r   r   r   r   r   r   r   r   @test_warns_sphinx_yield_list_of_custom_class_without_description  r$   zZTestDocstringCheckerYield.test_warns_sphinx_yield_list_of_custom_class_without_descriptionc                 C   r"   )Nz
        def my_func(self):
            """This is a docstring.

            Yields:
                list(:class:`mymodule.Class`):
            """
            yield [mymodule.Class()]
        r   r   r   r   r   r   r   r   @test_warns_google_yield_list_of_custom_class_without_description*  r)   zZTestDocstringCheckerYield.test_warns_google_yield_list_of_custom_class_without_descriptionc                 C   r"   )Nz
        def my_func(self):
            """This is a docstring.

            Yields
            -------
                list(:class:`mymodule.Class`)
            """
            yield [mymodule.Class()]
        r   r   r   r   r   r   r   r   ?test_warns_numpy_yield_list_of_custom_class_without_description9  s   



"zYTestDocstringCheckerYield.test_warns_numpy_yield_list_of_custom_class_without_descriptionc                 C   r
   )Nz
        def my_func(self):
            """This is a docstring.

            Yields:
                int or None: One, or sometimes None.
            """
            if a_func():
                yield None
            yield 1
        r   r   r   r   visit_functiondefr   r   r   r   r   7test_ignores_google_redundant_yield_doc_multiple_yieldsL  r1   zQTestDocstringCheckerYield.test_ignores_google_redundant_yield_doc_multiple_yieldsc                 C   r
   )Na'  
        def my_func(self):
            """This is a docstring.

            Yields
            -------
                int
                    One
                None
                    Sometimes
            """
            if a_func():
                yield None
            yield 1
        r;   r=   r   r   r   6test_ignores_numpy_redundant_yield_doc_multiple_yields[  s   

"zPTestDocstringCheckerYield.test_ignores_numpy_redundant_yield_doc_multiple_yieldsc                 C   N   t d}| td|d | j| W d    d S 1 s w   Y  d S )Nz
        def my_func(self):
            """This is a docstring.

            Yields:
                int: One
            """
            return 1
        redundant-yields-docr   r   r   r   r   r   r<   r=   r   r   r   ,test_warns_google_redundant_yield_doc_returnq  s   
	
"zFTestDocstringCheckerYield.test_warns_google_redundant_yield_doc_returnc                 C   r@   )Nz
        def my_func(self):
            """This is a docstring.

            Yields
            -------
                int
                    One
            """
            return 1
        rA   r   rB   r=   r   r   r   +test_warns_numpy_redundant_yield_doc_return  s   

"zETestDocstringCheckerYield.test_warns_numpy_redundant_yield_doc_returnN)!__name__
__module____qualname____doc__r   ZCHECKER_CLASSr   r   r    r!   r#   r%   r&   r(   r*   r+   r,   r-   r/   r0   r2   r3   r4   r5   r6   r7   r8   r9   r:   r>   r?   rC   rD   r   r   r   r   r	      s<    
	r	   )rH   
__future__r   r   r   r   Zpylint.testutilsr   r   r   Zpylint.extensions.docparamsr   r	   r   r   r   r   <module>   s   