o
    ¦ÜÓh  ã                   @   sL   d dl mZ d dlmZmZmZmZmZm	Z	 d dl
mZ G dd„ deƒZdS )é    )Úmessages)ÚFunctionScopeÚ
ClassScopeÚModuleScopeÚArgumentÚFunctionDefinitionÚ
Assignment)ÚTestCasec                   @   s8   e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zd
d„ ZdS )ÚTestCodeSegmentsz(
    Tests for segments of a module
    c                 C   ó$   | j ddd | j dtjdd d S )NzH
        def foo():
            def bar():
                pass
        T©Ú
is_segmentzI
        def foo():
            def bar():
                x = 0
        ©ÚflakesÚmÚUnusedVariable©Úself© r   úU/var/www/html/ai/venv/lib/python3.10/site-packages/pyflakes/test/test_code_segment.pyÚtest_function_segment   ó   ü
üz&TestCodeSegments.test_function_segmentc                 C   r   )NzH
        class Foo:
            class Bar:
                pass
        Tr   zI
        class Foo:
            def bar():
                x = 0
        r   r   r   r   r   Útest_class_segment   r   z#TestCodeSegments.test_class_segmentc                 C   sB  | j ddd}|j}dd„ |D ƒ}dd„ |D ƒ}dd„ |D ƒ}|  t|ƒd¡ |  t|ƒd	¡ |  t|ƒd	¡ |d }|d }|  |t¡ |  |t¡ |  d
|¡ |  d|¡ |  d|¡ |  d|¡ |  d|¡ |  d|¡ |  |d t¡ |  |d
 t	¡ |  |d t
¡ |  |d t
¡ |  |d t
¡ |  |d t
¡ d S )Nzi
        class Foo:
            x = 0
            def bar(a, b=1, *d, **e):
                pass
        Tr   c                 S   ó   g | ]	}|j tu r|‘qS r   ©Ú	__class__r   ©Ú.0Úscoper   r   r   Ú
<listcomp>/   ó    z5TestCodeSegments.test_scope_class.<locals>.<listcomp>c                 S   r   r   )r   r   r   r   r   r   r   1   r    c                 S   r   r   ©r   r   r   r   r   r   r   3   r    r   é   ÚxÚbarÚaÚbÚdÚe)r   Ú
deadScopesÚassertEqualÚlenÚassertIsInstancer   r   ÚassertInr   r   r   )r   ÚcheckerÚscopesÚmodule_scopesÚclass_scopesÚfunction_scopesÚclass_scopeÚfunction_scoper   r   r   Útest_scope_class&   s@   ûÿÿÿz!TestCodeSegments.test_scope_classc                 C   sx  | j ddd}|j}dd„ |D ƒ}dd„ |D ƒ}|  t|ƒd¡ |  t|ƒd¡ |d	 }|d }|  |t¡ |  |t¡ |  d
|¡ |  d|¡ |  d|¡ |  d|¡ |  d|¡ |  d|¡ |  d|¡ |  d|¡ |  d|¡ |  |d t¡ |  |d
 t¡ |  |d t¡ |  |d t¡ |  |d t¡ |  |d t¡ |  |d t¡ |  |d t¡ |  |d t¡ d S )Nzf
        def foo(a, b=1, *d, **e):
            def bar(f, g=1, *h, **i):
                pass
        Tr   c                 S   r   r   r   r   r   r   r   r   Z   r    z8TestCodeSegments.test_scope_function.<locals>.<listcomp>c                 S   r   r   r!   r   r   r   r   r   \   r    r   é   r"   r%   r&   r'   r(   r$   ÚfÚgÚhÚi)	r   r)   r*   r+   r,   r   r-   r   r   )r   r.   r/   r0   r2   Úfunction_scope_fooÚfunction_scope_barr   r   r   Útest_scope_functionR   sD   üÿÿz$TestCodeSegments.test_scope_functionc                 C   s   | j ddd d S )Nzasync def foo(): passTr   )r   r   r   r   r   Útest_scope_async_function€   s   z*TestCodeSegments.test_scope_async_functionN)	Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r5   r=   r>   r   r   r   r   r
      s    ,.r
   N)Úpyflakesr   r   Úpyflakes.checkerr   r   r   r   r   r   Úpyflakes.test.harnessr	   r
   r   r   r   r   Ú<module>   s     