§
    îyIfžg  ã                   ór  — d Z ddlZddlZddlZddlZddlZddlZddlZddlm	Z	 ddl
mZ ddlmZ ddlmZmZmZmZmZ ddlmZmZ d„ Z G d	„ d
¦  «        Z G d„ d¦  «        Z G d„ d¦  «        Z G d„ de¦  «        Z G d„ de¦  «        Z G d„ de¦  «        Z G d„ de¦  «        Z G d„ de¦  «        ZdS )z)
Tests for L{pyflakes.scripts.pyflakes}.
é    N)ÚPYPY)ÚUnusedImport)ÚReporter)ÚmainÚcheckÚ	checkPathÚcheckRecursiveÚiterSourceCode)ÚTestCaseÚskipIfc                 ó€   — t           j        | c}t           _        	  ||i |¤Ž|t           _        S # |t           _        w xY w)z?
    Call C{f} with C{sys.stderr} redirected to C{stderr}.
    )ÚsysÚstderr)r   ÚfÚargsÚkwargsÚouters        úJ/var/www/piapp/venv/lib/python3.11/site-packages/pyflakes/test/test_api.pyÚwithStderrTor      sG   € õ œ: vÐ€U�CŒJðØˆq�$Ð!˜&Ð!Ð!à�Œ
ˆ
ø�U�Œ
ÐÐÐÐs   ›/ ¯=c                   ó   — e Zd ZdZdd„ZdS )ÚNodez
    Mock an AST node.
    r   c                 ó"   — || _         || _        d S ©N)ÚlinenoÚ
col_offset)Úselfr   r   s      r   Ú__init__zNode.__init__)   s   € ØˆŒØ$ˆŒˆˆó    N)r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   © r   r   r   r   %   s2   € € € € € ðð ð%ð %ð %ð %ð %ð %r   r   c                   ó$   — e Zd ZdZd„ Zd„ Zd„ ZdS )ÚSysStreamCapturingzContext manager capturing sys.stdin, sys.stdout and sys.stderr.

    The file handles are replaced with a StringIO object.
    c                 óT   — t          j        |pdt          j        ¬¦  «        | _        d S )NÚ ©Únewline)ÚioÚStringIOÚosÚlinesepÚ_stdin)r   Ústdins     r   r   zSysStreamCapturing.__init__4   s"   € Ý”k % +¨2µr´zÐBÑBÔBˆŒˆˆr   c                 óN  — t           j        | _        t           j        | _        t           j        | _        | j        t           _        t          j	        t          j        ¬¦  «        xt           _        | _        t          j	        t          j        ¬¦  «        xt           _        | _        | S )Nr(   )r   r/   Ú_orig_stdinÚstdoutÚ_orig_stdoutr   Ú_orig_stderrr.   r*   r+   r,   r-   Ú_stdout_stringioÚ_stderr_stringio©r   s    r   Ú	__enter__zSysStreamCapturing.__enter__7   sj   € Ýœ9ˆÔÝœJˆÔÝœJˆÔà”K�Œ	Ý-/¬[ÅÄÐ-LÑ-LÔ-LÐL�Œ
�TÔ*Ý-/¬[ÅÄÐ-LÑ-LÔ-LÐL�Œ
�TÔ*àˆr   c                 óä   — | j                              ¦   «         | _        | j                             ¦   «         | _        | j        t          _        | j        t          _	        | j
        t          _        d S r   )r5   ÚgetvalueÚoutputr6   Úerrorr1   r   r/   r3   r2   r4   r   )r   r   s     r   Ú__exit__zSysStreamCapturing.__exit__B   sP   € ØÔ+×4Ò4Ñ6Ô6ˆŒØÔ*×3Ò3Ñ5Ô5ˆŒ
àÔ$�Œ	ØÔ&�Œ
ØÔ&�Œ
ˆ
ˆ
r   N)r   r    r!   r"   r   r8   r=   r#   r   r   r%   r%   .   sN   € € € € € ðð ð
Cð Cð Cð	ð 	ð 	ð'ð 'ð 'ð 'ð 'r   r%   c                   ó*   — e Zd ZdZd„ Zd„ Zd„ Zd„ ZdS )ÚLoggingReporterzK
    Implementation of Reporter that just appends any error to a list.
    c                 ó   — || _         dS )zh
        Construct a C{LoggingReporter}.

        @param log: A list to append log messages to.
        N)Úlog)r   rA   s     r   r   zLoggingReporter.__init__P   s   € ð ˆŒˆˆr   c                 óX   — | j                              dt          |¦  «        f¦  «         d S )NÚflake)rA   ÚappendÚstr)r   Úmessages     r   rC   zLoggingReporter.flakeX   s'   € ØŒ�Š˜¥# g¡,¤,Ð/Ñ0Ô0Ð0Ð0Ð0r   c                 ó@   — | j                              d||f¦  «         d S )NÚunexpectedError©rA   rD   )r   ÚfilenamerF   s      r   rH   zLoggingReporter.unexpectedError[   s$   € ØŒ�ŠÐ*¨H°gÐ>Ñ?Ô?Ð?Ð?Ð?r   c                 óF   — | j                              d|||||f¦  «         d S )NÚsyntaxErrorrI   )r   rJ   Úmsgr   ÚoffsetÚlines         r   rL   zLoggingReporter.syntaxError^   s)   € ØŒ�Š˜¨°#°v¸vÀtÐLÑMÔMÐMÐMÐMr   N)r   r    r!   r"   r   rC   rH   rL   r#   r   r   r?   r?   K   sb   € € € € € ðð ðð ð ð1ð 1ð 1ð@ð @ð @ðNð Nð Nð Nð Nr   r?   c                   óN   — e Zd ZdZd„ Zd„ Zd„ Zd„ Zd„ Zd„ Z	d„ Z
d	„ Zd
„ Zd„ ZdS )ÚTestIterSourceCodez&
    Tests for L{iterSourceCode}.
    c                 ó6   — t          j        ¦   «         | _        d S r   )ÚtempfileÚmkdtempÚtempdirr7   s    r   ÚsetUpzTestIterSourceCode.setUpg   s   € ÝÔ'Ñ)Ô)ˆŒˆˆr   c                 ó8   — t          j        | j        ¦  «         d S r   ©ÚshutilÚrmtreerU   r7   s    r   ÚtearDownzTestIterSourceCode.tearDownj   ó   € ÝŒ�d”lÑ#Ô#Ð#Ð#Ð#r   c                 óŠ   — |sJ ‚t          j        j        | j        g|¢R Ž }t	          |d¦  «                             ¦   «          |S )NÚa)r,   ÚpathÚjoinrU   ÚopenÚclose)r   ÚpartsÚfpaths      r   ÚmakeEmptyFilez TestIterSourceCode.makeEmptyFilem   sG   € ØˆˆˆÝ””˜Tœ\Ð2¨EÐ2Ð2Ð2ˆÝˆU�CÑÔ×ÒÑ Ô Ð Øˆr   c                 ór   — |                       t          t          | j        g¦  «        ¦  «        g ¦  «         dS )zB
        There are no Python files in an empty directory.
        N)ÚassertEqualÚlistr
   rU   r7   s    r   Útest_emptyDirectoryz&TestIterSourceCode.test_emptyDirectorys   s4   € ð 	×Ò��n¨d¬l¨^Ñ<Ô<Ñ=Ô=¸rÑBÔBÐBÐBÐBr   c                 óž   — |                       d¦  «        }|                      t          t          | j        g¦  «        ¦  «        |g¦  «         dS )zd
        If the directory contains one Python file, C{iterSourceCode} will find
        it.
        úfoo.pyN©re   rg   rh   r
   rU   )r   Ú	childpaths     r   Útest_singleFilez"TestIterSourceCode.test_singleFiley   sI   € ð
 ×&Ò& xÑ0Ô0ˆ	Ø×Ò��n¨d¬l¨^Ñ<Ô<Ñ=Ô=À	¸{ÑKÔKÐKÐKÐKr   c                 óœ   — |                       d¦  «         |                      t          t          | j        g¦  «        ¦  «        g ¦  «         dS )zJ
        Files that are not Python source files are not included.
        zfoo.pycNrl   r7   s    r   Útest_onlyPythonSourcez(TestIterSourceCode.test_onlyPythonSource�   sH   € ð 	×Ò˜9Ñ%Ô%Ð%Ø×Ò��n¨d¬l¨^Ñ<Ô<Ñ=Ô=¸rÑBÔBÐBÐBÐBr   c                 ó  — t          j        t           j                             | j        d¦  «        ¦  «         |                      dd¦  «        }|                      dd¦  «         t          j        t           j                             | j        d¦  «        ¦  «         |                      dd¦  «        }|                      d¦  «        }|                      t          t          | j        g¦  «        ¦  «        t          |||g¦  «        ¦  «         dS )zk
        If the Python files are hidden deep down in child directories, we will
        find them.
        Úfooúa.pyza.py~Úbarúb.pyzc.pyN)	r,   Úmkdirr_   r`   rU   re   rg   Úsortedr
   )r   ÚapathÚbpathÚcpaths       r   Útest_recursesz TestIterSourceCode.test_recursesˆ   sæ   € õ
 	Œ•”—’˜dœl¨EÑ2Ô2Ñ3Ô3Ð3Ø×"Ò" 5¨&Ñ1Ô1ˆØ×Ò˜5 'Ñ*Ô*Ð*Ý
Œ•”—’˜dœl¨EÑ2Ô2Ñ3Ô3Ð3Ø×"Ò" 5¨&Ñ1Ô1ˆØ×"Ò" 6Ñ*Ô*ˆØ×ÒÝ•> 4¤< .Ñ1Ô1Ñ2Ô2Ý�E˜5 %Ð(Ñ)Ô)ñ	+ô 	+ð 	+ð 	+ð 	+r   c                 óÞ  — t           j                             | j        d¦  «        }t	          |d¦  «        5 }|                     d¦  «         ddd¦  «         n# 1 swxY w Y   |                      d¦  «         t	          t           j                             | j        d¦  «        d¦  «        5 }|                     d¦  «         ddd¦  «         n# 1 swxY w Y   t           j                             | j        d¦  «        }t	          |d¦  «        5 }|                     d	¦  «         ddd¦  «         n# 1 swxY w Y   t           j                             | j        d
¦  «        }t	          |d¦  «        5 }|                     d¦  «         ddd¦  «         n# 1 swxY w Y   t           j                             | j        d¦  «        }t	          |d¦  «        5 }|                     d¦  «         ddd¦  «         n# 1 swxY w Y   t           j                             | j        d¦  «        }t	          |d¦  «        5 }|                     d¦  «         ddd¦  «         n# 1 swxY w Y   t           j                             | j        d¦  «        }t	          |d¦  «        5 }|                     d¦  «         ddd¦  «         n# 1 swxY w Y   t           j                             | j        d¦  «        }t	          |d¦  «        5 }|                     d¦  «         ddd¦  «         n# 1 swxY w Y   |                      t          t          | j        g¦  «        ¦  «        t          ||||||g¦  «        ¦  «         dS )zd
        Find Python files that don't end with `.py`, but contain a Python
        shebang.
        r^   Úwz#!/usr/bin/env python
NÚbÚczhello
world
Úez#!/usr/bin/env python3
r   z#!/usr/bin/env pythonw
Úgz#!/usr/bin/python3 -u
Úiz#!/usr/local/bin/python3d
Újz#! /usr/bin/env python3.8m
Úlz#!/bin/sh
#!/usr/bin/python
)
r,   r_   r`   rU   ra   Úwritere   rg   rw   r
   )	r   ÚpythonÚfdÚpython3ÚpythonwÚpython3argsÚpython3dÚ	python38mÚnotfirsts	            r   Útest_shebangzTestIterSourceCode.test_shebang—   sÜ  € õ
 ”—’˜dœl¨CÑ0Ô0ˆÝ�&˜#ÑÔð 	0 "Ø�HŠHÐ.Ñ/Ô/Ð/ð	0ð 	0ð 	0ñ 	0ô 	0ð 	0ð 	0ð 	0ð 	0ð 	0ð 	0øøøð 	0ð 	0ð 	0ð 	0ð 	×Ò˜3ÑÔÐå•"”'—,’,˜tœ|¨SÑ1Ô1°3Ñ7Ô7ð 	'¸2Ø�HŠHÐ%Ñ&Ô&Ð&ð	'ð 	'ð 	'ñ 	'ô 	'ð 	'ð 	'ð 	'ð 	'ð 	'ð 	'øøøð 	'ð 	'ð 	'ð 	'õ ”'—,’,˜tœ|¨SÑ1Ô1ˆÝ�'˜3ÑÔð 	1 2Ø�HŠHÐ/Ñ0Ô0Ð0ð	1ð 	1ð 	1ñ 	1ô 	1ð 	1ð 	1ð 	1ð 	1ð 	1ð 	1øøøð 	1ð 	1ð 	1ð 	1õ ”'—,’,˜tœ|¨SÑ1Ô1ˆÝ�'˜3ÑÔð 	1 2Ø�HŠHÐ/Ñ0Ô0Ð0ð	1ð 	1ð 	1ñ 	1ô 	1ð 	1ð 	1ð 	1ð 	1ð 	1ð 	1øøøð 	1ð 	1ð 	1ð 	1õ ”g—l’l 4¤<°Ñ5Ô5ˆÝ�+˜sÑ#Ô#ð 	0 rØ�HŠHÐ.Ñ/Ô/Ð/ð	0ð 	0ð 	0ñ 	0ô 	0ð 	0ð 	0ð 	0ð 	0ð 	0ð 	0øøøð 	0ð 	0ð 	0ð 	0õ ”7—<’< ¤¨cÑ2Ô2ˆÝ�(˜CÑ Ô ð 	4 BØ�HŠHÐ2Ñ3Ô3Ð3ð	4ð 	4ð 	4ñ 	4ô 	4ð 	4ð 	4ð 	4ð 	4ð 	4ð 	4øøøð 	4ð 	4ð 	4ð 	4õ ”G—L’L ¤¨sÑ3Ô3ˆ	Ý�)˜SÑ!Ô!ð 	5 RØ�HŠHÐ3Ñ4Ô4Ð4ð	5ð 	5ð 	5ñ 	5ô 	5ð 	5ð 	5ð 	5ð 	5ð 	5ð 	5øøøð 	5ð 	5ð 	5ð 	5õ ”7—<’< ¤¨cÑ2Ô2ˆÝ�(˜CÑ Ô ð 	7 BØ�HŠHÐ5Ñ6Ô6Ð6ð	7ð 	7ð 	7ñ 	7ô 	7ð 	7ð 	7ð 	7ð 	7ð 	7ð 	7øøøð 	7ð 	7ð 	7ð 	7ð 	×ÒÝ•> 4¤< .Ñ1Ô1Ñ2Ô2ÝØ˜ ¨+°xØðñ ô ñ	ô 	ð 	ð 	ð 	s�   ¶AÁAÁAÂ+CÃCÃCÄD/Ä/D3Ä6D3Å/FÆFÆFÇG3Ç3G7Ç:G7È3IÉIÉIÊJ7Ê7J;Ê>J;Ë7LÌLÌ Lc                 óÄ  — t           j                             | j        d¦  «        }t           j                             | j        d¦  «        }t          j        |¦  «         |                      dd¦  «        }t          j        |¦  «         |                      dd¦  «        }|                      t          t          ||g¦  «        ¦  «        t          ||g¦  «        ¦  «         dS )zr
        L{iterSourceCode} can be given multiple directories.  It will recurse
        into each of them.
        rr   rt   rs   ru   N)	r,   r_   r`   rU   rv   re   rg   rw   r
   )r   ÚfoopathÚbarpathrx   ry   s        r   Útest_multipleDirectoriesz+TestIterSourceCode.test_multipleDirectoriesÅ   sÅ   € õ
 ”'—,’,˜tœ|¨UÑ3Ô3ˆÝ”'—,’,˜tœ|¨UÑ3Ô3ˆÝ
Œ�ÑÔÐØ×"Ò" 5¨&Ñ1Ô1ˆÝ
Œ�ÑÔÐØ×"Ò" 5¨&Ñ1Ô1ˆØ×ÒÝ•> 7¨GÐ"4Ñ5Ô5Ñ6Ô6Ý�E˜5�>Ñ"Ô"ñ	$ô 	$ð 	$ð 	$ð 	$r   c                 ó”   — |                       d¦  «        }|                      t          t          |g¦  «        ¦  «        |g¦  «         dS )z‹
        If one of the paths given to L{iterSourceCode} is not a directory but
        a file, it will include that in its output.
        ze.pyN)re   rg   rh   r
   )r   Úepaths     r   Útest_explicitFilesz%TestIterSourceCode.test_explicitFilesÔ   sR   € ð
 ×"Ò" 6Ñ*Ô*ˆØ×Ò��n¨e¨WÑ5Ô5Ñ6Ô6Ø˜ñ	"ô 	"ð 	"ð 	"ð 	"r   N)r   r    r!   r"   rV   r[   re   ri   rn   rp   r{   rŽ   r’   r•   r#   r   r   rQ   rQ   b   s¾   € € € € € ðð ð*ð *ð *ð$ð $ð $ðð ð ðCð Cð CðLð Lð LðCð Cð Cð+ð +ð +ð,ð ,ð ,ð\$ð $ð $ð"ð "ð "ð "ð "r   rQ   c                   ó6   — e Zd ZdZd„ Zd„ Zd„ Zd„ Zd„ Zd„ Z	dS )	ÚTestReporterz 
    Tests for L{Reporter}.
    c                 óÎ   — t          j        ¦   «         }t          d|¦  «        }|                     ddddd¦  «         |                      d|                     ¦   «         ¦  «         dS )a  
        C{syntaxError} reports that there was a syntax error in the source
        file.  It reports to the error stream and includes the filename, line
        number, error message, actual line of source and a caret pointing to
        where the error is.
        Nrk   ú	a problemé   é   úbad line of sourcez2foo.py:3:8: a problem
bad line of source
       ^
©r*   r+   r   rL   rg   r:   ©r   ÚerrÚreporters      r   Útest_syntaxErrorzTestReporter.test_syntaxErrorã   so   € õ Œk‰mŒmˆÝ˜D #Ñ&Ô&ˆØ×Ò˜X {°A°qÐ:NÑOÔOÐOØ×Òðð �LŠL‰NŒNñ		ô 	ð 	ð 	ð 	r   c                 óÎ   — t          j        ¦   «         }t          d|¦  «        }|                     ddddd¦  «         |                      d|                     ¦   «         ¦  «         dS )zy
        C{syntaxError} doesn't include a caret pointing to the error if
        C{offset} is passed as C{None}.
        Nrk   r™   rš   rœ   z'foo.py:3: a problem
bad line of source
r�   rž   s      r   Útest_syntaxErrorNoOffsetz%TestReporter.test_syntaxErrorNoOffsetó   ss   € õ
 Œk‰mŒmˆÝ˜D #Ñ&Ô&ˆØ×Ò˜X {°A°tØ1ñ	3ô 	3ð 	3à×Òð$à�LŠL‰NŒNñ	ô 	ð 	ð 	ð 	r   c                 óÎ   — t          j        ¦   «         }t          d|¦  «        }|                     ddddd¦  «         |                      d|                     ¦   «         ¦  «         dS )z¬
        C{syntaxError} doesn't include text or nonsensical offsets if C{text} is C{None}.

        This typically happens when reporting syntax errors from stdin.
        Nú<stdin>r™   r   z<stdin>:1:1: a problem
r�   rž   s      r   Útest_syntaxErrorNoTextz#TestReporter.test_syntaxErrorNoText  s_   € õ Œk‰mŒmˆÝ˜D #Ñ&Ô&ˆØ×Ò˜Y¨°Q¸¸4Ñ@Ô@Ð@Ø×ÒÐ4°s·|²|±~´~ÑFÔFÐFÐFÐFr   c           	      óL  — t          j        ¦   «         }ddg}t          d|¦  «        }|                     dddt	          |d         ¦  «        dz   d	                     |¦  «        ¦  «         |                      d
|d         z   d	z   dz   dz   |                     ¦   «         ¦  «         dS )z¸
        If there's a multi-line syntax error, then we only report the last
        line.  The offset is adjusted so that it is relative to the start of
        the last line.
        rœ   zmore bad lines of sourceNrk   r™   rš   r   é   ú
zfoo.py:3:25: a problem
éÿÿÿÿz                        ú^
)r*   r+   r   rL   Úlenr`   rg   r:   )r   rŸ   Úlinesr    s       r   Útest_multiLineSyntaxErrorz&TestReporter.test_multiLineSyntaxError  sÁ   € õ Œk‰mŒmˆà Ø&ð
ˆõ ˜D #Ñ&Ô&ˆØ×Ò˜X {°Aµs¸5À¼8±}´}ÀqÑ7HØ!ŸYšY uÑ-Ô-ñ	/ô 	/ð 	/à×ÒØ'Ø�2ŒYñØñàñàñð �LŠL‰NŒNñ		ô 	ð 	ð 	ð 	r   c                 óÈ   — t          j        ¦   «         }t          d|¦  «        }|                     dd¦  «         |                      d|                     ¦   «         ¦  «         dS )zO
        C{unexpectedError} reports an error processing a source file.
        Nz	source.pyzerror messagezsource.py: error message
)r*   r+   r   rH   rg   r:   rž   s      r   Útest_unexpectedErrorz!TestReporter.test_unexpectedError   sY   € õ Œk‰mŒmˆÝ˜D #Ñ&Ô&ˆØ× Ò  ¨oÑ>Ô>Ð>Ø×ÒÐ5°s·|²|±~´~ÑFÔFÐFÐFÐFr   c                 ó  — t          j        ¦   «         }t          |d¦  «        }t          dt	          d¦  «        d¦  «        }|                     |¦  «         |                      |                     ¦   «         |› d�¦  «         dS )z„
        C{flake} reports a code warning from Pyflakes.  It is exactly the
        str() of a L{pyflakes.messages.Message}.
        Nrk   é*   rt   r©   )r*   r+   r   r   r   rC   rg   r:   )r   Úoutr    rF   s       r   Ú
test_flakezTestReporter.test_flake)  sq   € õ
 Œk‰mŒmˆÝ˜C Ñ&Ô&ˆÝ˜x­¨b©¬°5Ñ9Ô9ˆØ�Š�wÑÔÐØ×Ò˜Ÿš™œ¨G¨¨¨Ñ8Ô8Ð8Ð8Ð8r   N)
r   r    r!   r"   r¡   r£   r¦   r®   r°   r´   r#   r   r   r—   r—   Þ   s~   € € € € € ðð ðð ð ð ð ð ð	Gð 	Gð 	Gðð ð ð(Gð Gð Gð	9ð 	9ð 	9ð 	9ð 	9r   r—   c                   óÚ   — e Zd ZdZej        d„ ¦   «         Zd„ Zd„ Zd„ Z	d„ Z
d„ Zd„ Zd	„ Zd
„ Zd„ Zd„ Zd„ Z eej        dk    d¦  «        d„ ¦   «         Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ ZdS )Ú
CheckTestszL
    Tests for L{check} and L{checkPath} which check a file for flakes.
    c              #   óh  K  — t          j        ¦   «         \  }}	 t          j        |d¦  «        5 }t	          |d¦  «        s|                     d¦  «        }|                     |¦  «         ddd¦  «         n# 1 swxY w Y   |V — t          j        |¦  «         dS # t          j        |¦  «         w xY w)zV
        Make a temporary file containing C{content} and return a path to it.
        ÚwbÚdecodeÚasciiN)rS   Úmkstempr,   ÚfdopenÚhasattrÚencoder…   Úremove)r   Úcontentr‡   Únamer   s        r   ÚmakeTempFilezCheckTests.makeTempFile:  sæ   è è € õ
 Ô#Ñ%Ô%‰ˆˆDð	Ý”˜2˜tÑ$Ô$ð !¨Ý˜w¨Ñ1Ô1ð 6Ø%Ÿnšn¨WÑ5Ô5�GØ—’˜Ñ Ô Ð ð!ð !ð !ñ !ô !ð !ð !ð !ð !ð !ð !øøøð !ð !ð !ð !ð ˆJˆJˆJåŒI�d‰OŒOˆOˆOˆOø�BŒI�d‰OŒOˆOˆOøøøs.   šB ¯;A6Á*B Á6A:Á:B Á=A:Á>B ÂB1c                 óð   — t          j        ¦   «         }t          |t          |¦  «        }|                      ||                     ¦   «         ft          |¦  «        d                     |¦  «        f¦  «         dS )z²
        Assert that C{path} causes errors.

        @param path: A path to a file to check.
        @param errorList: A list of errors expected to be printed to stderr.
        r'   N)r*   r+   r   r   rg   r:   r¬   r`   )r   r_   Ú	errorListrŸ   Úcounts        r   ÚassertHasErrorszCheckTests.assertHasErrorsI  sp   € õ Œk‰mŒmˆÝ˜S¥)¨TÑ2Ô2ˆØ×ÒØ�C—L’L‘N”NÐ#¥c¨)¡n¤n°b·g²g¸iÑ6HÔ6HÐ%Iñ	Kô 	Kð 	Kð 	Kð 	Kr   c                 óL   — g }t          |¦  «        }t          ||¦  «        }||fS )a‘  
        Get any warnings or errors reported by pyflakes for the file at C{path}.

        @param path: The path to a Python file on disk that pyflakes will check.
        @return: C{(count, log)}, where C{count} is the number of warnings or
            errors generated, and log is a list of those warnings, presented
            as structured data.  See L{LoggingReporter} for more details.
        )r?   r   )r   r_   rA   r    rÅ   s        r   Ú	getErrorszCheckTests.getErrorsU  s/   € ð ˆÝ" 3Ñ'Ô'ˆÝ˜$ Ñ)Ô)ˆØ�cˆzÐr   c                 óR   — ddl m} |                      |j        t          ¦  «         d S )Nr   )Úpyflakes)Úpyflakes.scriptsrÊ   ÚassertIsr   )r   Úscript_pyflakess     r   Útest_legacyScriptzCheckTests.test_legacyScriptc  s1   € Ø@Ð@Ð@Ð@Ð@Ð@Ø�Š�oÔ/µÑ;Ô;Ð;Ð;Ð;r   c                 óŽ   — |                       d¦  «        5 }|                      |g ¦  «         ddd¦  «         dS # 1 swxY w Y   dS )z§
        Source which doesn't end with a newline shouldn't cause any
        exception to be raised nor an error indicator to be returned by
        L{check}.
        zdef foo():
	pass
	N©rÂ   rÆ   )r   ÚfNames     r   Útest_missingTrailingNewlinez&CheckTests.test_missingTrailingNewlineg  s�   € ð ×ÒÐ7Ñ8Ô8ð 	,¸EØ× Ò  ¨Ñ+Ô+Ð+ð	,ð 	,ð 	,ñ 	,ô 	,ð 	,ð 	,ð 	,ð 	,ð 	,ð 	,ð 	,øøøð 	,ð 	,ð 	,ð 	,ð 	,ð 	,ó   –:º>Á>c                 ó�   — |                       d¦  «        \  }}|                      |d¦  «         |                      |dg¦  «         dS )z:
        L{checkPath} handles non-existing files.
        Úextremoé   )rH   rÕ   zNo such file or directoryN)rÈ   rg   )r   rÅ   Úerrorss      r   Útest_checkPathNonExistingz$CheckTests.test_checkPathNonExistingp  s_   € ð Ÿš yÑ1Ô1‰ˆˆvØ×Ò˜ Ñ"Ô"Ð"Ø×ÒØØHÐIñ	Kô 	Kð 	Kð 	Kð 	Kr   c                 ó*  — d}d„ }	  ||¦  «         |                       ¦   «          n_# t          $ rR}t          sAt          j        dk     r1|                      |j                             d¦  «        dk    ¦  «         Y d}~nd}~ww xY w|                      |¦  «        5 }t          rd}nt          j        dk    rd}nd	}t          st          j        dk    rd
}nd}|  	                    |d|||d|dz
  z  fz  g¦  «         ddd¦  «         dS # 1 swxY w Y   dS )zÏ
        Source which includes a syntax error which results in the raised
        L{SyntaxError.text} containing multiple lines of source are reported
        with only the last line of that source.
        zCdef foo():
    '''

def bar():
    pass

def baz():
    '''quux'''
c                 ó$   — t          | ¦  «         d S r   )Úexec)Úsources    r   Úevaluatez6CheckTests.test_multilineSyntaxError.<locals>.evaluate�  s   € Ý�‰LŒLˆLˆLˆLr   ©rš   é
   r©   rÖ   Nz=end of file (EOF) while scanning triple-quoted string literalz>unterminated triple-quoted string literal (detected at line 8)zinvalid syntaxé   r›   z%s:8:%d: %s
    '''quux'''
%s^
ú )
ÚfailÚSyntaxErrorr   r   Úversion_infoÚ
assertTrueÚtextrÅ   rÂ   rÆ   )r   rÜ   rÝ   r€   Ú
sourcePathrF   Úcolumns          r   Útest_multilineSyntaxErrorz$CheckTests.test_multilineSyntaxErrorz  s   € ð	ˆð	ð 	ð 	ð	ØˆH�VÑÔÐð
 �IŠI‰KŒKˆKˆKøõ	 ð 	8ð 	8ð 	8Ýð 8�CÔ,¨wÒ6Ð6Ø—’ ¤§¢¨TÑ 2Ô 2°QÒ 6Ñ7Ô7Ð7øøøøøøøøøð	8øøøð ×Ò˜vÑ&Ô&ð 	:¨*Ýð +ØY��ÝÔ! WÒ,Ð,ØZ��à*�åð •sÔ'¨7Ò2Ð2Ø��à�Ø× Ò Øðð �6˜7 C¨6°A©:Ñ$6Ð7ñ	8ð 9ñ:ô :ð :ð	:ð 	:ð 	:ñ 	:ô 	:ð 	:ð 	:ð 	:ð 	:ð 	:ð 	:ð 	:øøøð 	:ð 	:ð 	:ð 	:ð 	:ð 	:s(   ‡' §
B±AA>Á>BÂA DÄDÄDc                 óF  — |                       d¦  «        5 }t          rd}nt          j        dk    rd}nd}t          st          j        dk    rd}nd}d|d	z
  z  }d
                     ||||¦  «        }|                      ||g¦  «         ddd¦  «         dS # 1 swxY w Y   dS )ú“
        The error reported for source files which end prematurely causing a
        syntax error reflects the cause for the syntax error.
        zdef foo(zparenthesis is never closedrÞ   z'(' was never closedzunexpected EOF while parsingr›   é	   rá   rÖ   z{}:1:{}: {}
def foo(
{}^
N)rÂ   r   r   rä   ÚformatrÆ   )r   rç   rM   rè   ÚspacesÚexpecteds         r   Útest_eofSyntaxErrorzCheckTests.test_eofSyntaxError«  s	  € ð
 ×Ò˜zÑ*Ô*ð 	9¨jÝð 5Ø3��ÝÔ! WÒ,Ð,Ø,��à4�åð •sÔ'¨7Ò2Ð2Ø��à�à˜F Q™JÑ'ˆFØ5×<Ò<Ø˜F C¨ñô ˆHð × Ò  ¨h¨ZÑ8Ô8Ð8ð%	9ð 	9ð 	9ñ 	9ô 	9ð 	9ð 	9ð 	9ð 	9ð 	9ð 	9ð 	9øøøð 	9ð 	9ð 	9ð 	9ð 	9ð 	9s   –A3BÂBÂBc                 ó–   — |                       d¦  «        5 }|                      ||› d�g¦  «         ddd¦  «         dS # 1 swxY w Y   dS )rë   zif True:
	foo =z$:2:7: invalid syntax
	foo =
	     ^
NrÐ   ©r   rç   s     r   Útest_eofSyntaxErrorWithTabz%CheckTests.test_eofSyntaxErrorWithTabÄ  s¬   € ð
 ×ÒÐ2Ñ3Ô3ð 	°zØ× Ò Øàðð ð ð ñô ð ð	ð 	ð 	ñ 	ô 	ð 	ð 	ð 	ð 	ð 	ð 	ð 	øøøð 	ð 	ð 	ð 	ð 	ð 	s   –>¾AÁAc                 ó‚  — d}|                       |¦  «        5 }t          j        dk    rd}nd}t          rt          j        dk    rd}n2t          rd}n(t          j        dk    rd}nt          j        dk    rd	}nd
}d|dz
  z  dz   }|                      ||› d|› d|› d|› �g¦  «         ddd¦  «         dS # 1 swxY w Y   dS )zÎ
        Source which has a non-default argument following a default argument
        should include the line number of the syntax error.  However these
        exceptions do not include an offset.
        z def foo(bar=baz, bax):
    pass
©rš   rà   z<parameter without a default follows parameter with a defaultz-non-default argument follows default argument©rš   rì   é   r›   rÞ   é   rì   rá   rÖ   r«   z:1:z: z
def foo(bar=baz, bax):
N)rÂ   r   rä   r   rÆ   )r   rÜ   rç   rM   rè   Ú	last_lines         r   Ú(test_nonDefaultFollowsDefaultSyntaxErrorz3CheckTests.test_nonDefaultFollowsDefaultSyntaxErrorÒ  s]  € ðˆð ×Ò˜vÑ&Ô&ð 	¨*ÝÔ 7Ò*Ð*ØT��àE�åð 	�Ô(¨FÒ2Ð2Ø��Ýð Ø��ÝÔ! WÒ,Ð,Ø��ÝÔ! VÒ+Ð+Ø��à�Ø˜v¨™zÑ*¨UÑ2ˆIØ× Ò Øàðð Øðð Øðð ð ðð ð ñô ð ð#	ð 	ð 	ñ 	ô 	ð 	ð 	ð 	ð 	ð 	ð 	ð 	øøøð 	ð 	ð 	ð 	ð 	ð 	s   ˜BB4Â4B8Â;B8c           
      ó"  — d}|                       |¦  «        5 }t          j        dk    rd}nt          sd}nd}d|dz
  z  dz   }d	|z  }d
}|                      |d                     ||||¦  «        g¦  «         ddd¦  «         dS # 1 swxY w Y   dS )zÊ
        Source which has a non-keyword argument after a keyword argument should
        include the line number of the syntax error.  However these exceptions
        do not include an offset.
        zfoo(bar=baz, bax)
rö   é   é   é   rá   rÖ   r«   z%d:z,positional argument follows keyword argumentz{}:1:{} {}
foo(bar=baz, bax)
{}N)rÂ   r   rä   r   rÆ   rí   )r   rÜ   rç   rè   rù   Ú	columnstrrF   s          r   Ú&test_nonKeywordAfterKeywordSyntaxErrorz1CheckTests.test_nonKeywordAfterKeywordSyntaxErrorõ  s  € ðˆð ×Ò˜vÑ&Ô&ð 	:¨*ÝÔ 6Ò)Ð)Ø��Ýð Ø��à�Ø˜v¨™zÑ*¨UÑ2ˆIØ ™ˆIàDˆGà× Ò Øð÷ ‚fˆZ˜ G¨YÑ7Ô7ð9ñ:ô :ð :ð	:ð 	:ð 	:ñ 	:ô 	:ð 	:ð 	:ð 	:ð 	:ð 	:ð 	:ð 	:øøøð 	:ð 	:ð 	:ð 	:ð 	:ð 	:s   ˜ABÂBÂBc                 óB  — |                       d¦  «        5 }d}t          rt          j        dk    rd}n)t          rd}ndt          j        cxk    rdk     rn nd}nd}dd	|dz
  z  z  }d
||||fz  }|                      ||g¦  «         ddd¦  «         dS # 1 swxY w Y   dS )zI
        The invalid escape syntax raises ValueError in Python 2
        zfoo = '\xyz'rÖ   rö   r¨   é   rõ   rþ   z%s^
rá   zy%s:1:%d: (unicode error) 'unicodeescape' codec can't decode bytes in position 0-%d: truncated \xXX escape
foo = '\xyz'
%sN)rÂ   r   r   rä   rÆ   )r   rç   Úposition_endrè   rù   Údecoding_errors         r   Útest_invalidEscapezCheckTests.test_invalidEscape  s)  € ð
 ×Ò˜Ñ/Ô/ð 	.°:ØˆLÝð �Ô(¨FÒ2Ð2Ø��Ýð Ø��Ø�3Ô+Ð5Ð5Ò5Ð5¨gÒ5Ð5Ð5Ð5Ð5Ø��à�à 3¨&°1©*Ñ#5Ñ6ˆIðð 
�V˜\¨9Ð5ñ	6ˆNð × Ò Ø˜^Ð,ñ.ô .ð .ð'	.ð 	.ð 	.ñ 	.ô 	.ð 	.ð 	.ð 	.ð 	.ð 	.ð 	.ð 	.øøøð 	.ð 	.ð 	.ð 	.ð 	.ð 	.ó   –A1BÂBÂBÚwin32zunsupported on Windowsc                 ót  — t          j        ¦   «         dk    r|                      d¦  «         |                      d¦  «        5 }t          j        |d¦  «         |                      |¦  «        \  }}|                      |d¦  «         |                      |d|dfg¦  «         ddd¦  «         dS # 1 swxY w Y   dS )za
        If the source file is not readable, this is reported on standard
        error.
        r   z8root user can access all files regardless of permissionsr'   rÖ   rH   zPermission deniedN)r,   ÚgetuidÚskipTestrÂ   ÚchmodrÈ   rg   ©r   rç   rÅ   r×   s       r   Útest_permissionDeniedz CheckTests.test_permissionDenied,  s!  € õ Œ9‰;Œ;˜!ÒÐØ�MŠMð (ñ )ô )ð )à×Ò˜rÑ"Ô"ð 	H jÝŒH�Z Ñ#Ô#Ð#Ø ŸNšN¨:Ñ6Ô6‰MˆE�6Ø×Ò˜U AÑ&Ô&Ð&Ø×ÒØØ# ZÐ1DÐEÐFñHô Hð Hð		Hð 	Hð 	Hñ 	Hô 	Hð 	Hð 	Hð 	Hð 	Hð 	Hð 	Hð 	Høøøð 	Hð 	Hð 	Hð 	Hð 	Hð 	Hs   ÁAB-Â-B1Â4B1c                 óB  — |                       d¦  «        5 }|                      |¦  «        \  }}|                      |d¦  «         |                      |dt          t	          |t          d¦  «        d¦  «        ¦  «        fg¦  «         ddd¦  «         dS # 1 swxY w Y   dS )zc
        If the source file has a pyflakes warning, this is reported as a
        'flake'.
        z
import foorÖ   rC   rr   N)rÂ   rÈ   rg   rE   r   r   r  s       r   Útest_pyflakesWarningzCheckTests.test_pyflakesWarning=  sù   € ð
 ×Ò˜|Ñ,Ô,ð 	T°
Ø ŸNšN¨:Ñ6Ô6‰MˆE�6Ø×Ò˜U AÑ&Ô&Ð&Ø×ÒØ˜'¥3¥|°JÅÀQÁÄÈÑ'OÔ'OÑ#PÔ#PÐQÐRñTô Tð Tð	Tð 	Tð 	Tñ 	Tô 	Tð 	Tð 	Tð 	Tð 	Tð 	Tð 	Tð 	Tøøøð 	Tð 	Tð 	Tð 	Tð 	Tð 	Tr  c                 óÜ   — t          d¦  «        }d|z                       d¦  «        }|                      |¦  «        5 }|                      |g ¦  «         ddd¦  «         dS # 1 swxY w Y   dS )zU
        If source file declares the correct encoding, no error is reported.
        é&  z# coding: utf-8
x = "%s"
úutf-8N©Úchrr¾   rÂ   rÆ   ©r   ÚSNOWMANrÜ   rç   s       r   Útest_encodedFileUTF8zCheckTests.test_encodedFileUTF8H  s½   € õ �f‘+”+ˆðð ñ÷ Šv�g‰Œð 	ð ×Ò˜vÑ&Ô&ð 	1¨*Ø× Ò  ¨RÑ0Ô0Ð0ð	1ð 	1ð 	1ñ 	1ô 	1ð 	1ð 	1ð 	1ð 	1ð 	1ð 	1ð 	1øøøð 	1ð 	1ð 	1ð 	1ð 	1ð 	1s   ½A!Á!A%Á(A%c                 óŽ   — |                       d¦  «        5 }|                      |g ¦  «         ddd¦  «         dS # 1 swxY w Y   dS )zW
        Source files with Windows CR LF line endings are parsed successfully.
        zx = 42
NrÐ   rò   s     r   Útest_CRLFLineEndingszCheckTests.test_CRLFLineEndingsT  s�   € ð ×Ò˜|Ñ,Ô,ð 	1°
Ø× Ò  ¨RÑ0Ô0Ð0ð	1ð 	1ð 	1ñ 	1ô 	1ð 	1ð 	1ð 	1ð 	1ð 	1ð 	1ð 	1øøøð 	1ð 	1ð 	1ð 	1ð 	1ð 	1rÓ   c                 óä   — t          d¦  «        }d|z                       d¦  «        }|                      |¦  «        5 }|                      ||› d�g¦  «         ddd¦  «         dS # 1 swxY w Y   dS )ún
        If a source file contains bytes which cannot be decoded, this is
        reported on stderr.
        r  ú# coding: ascii
x = "%s"
r  zU:1:1: 'ascii' codec can't decode byte 0xe2 in position 21: ordinal not in range(128)
Nr  r  s       r   Útest_misencodedFileUTF8z"CheckTests.test_misencodedFileUTF8[  sç   € õ
 �f‘+”+ˆðð ñ÷ Šv�g‰Œð 	ð ×Ò˜vÑ&Ô&ð 	y¨*Ø× Ò ØØÐvÐvÐvÐwñyô yð yð	yð 	yð 	yñ 	yô 	yð 	yð 	yð 	yð 	yð 	yð 	yð 	yøøøð 	yð 	yð 	yð 	yð 	yð 	ys   ½A%Á%A)Á,A)c                 ó  — t          d¦  «        }d|z                       d¦  «        }|                      |¦  «        5 }t          j        dk     r|› d�}n|› d�}|                      ||g¦  «         ddd¦  «         dS # 1 swxY w Y   dS )r  r  r  zutf-16)rš   é   é   z: problem decoding source
z1:1: source code string cannot contain null bytes
N)r  r¾   rÂ   r   rä   rÆ   )r   r  rÜ   rç   rï   s        r   Útest_misencodedFileUTF16z#CheckTests.test_misencodedFileUTF16j  sí   € õ
 �f‘+”+ˆðð ñ÷ Šv�hÑÔð 	ð ×Ò˜vÑ&Ô&ð 	9¨*ÝÔ *Ò,Ð,Ø(ÐEÐEÐE��à(Ð\Ð\Ð\�à× Ò  ¨h¨ZÑ8Ô8Ð8ð	9ð 	9ð 	9ñ 	9ô 	9ð 	9ð 	9ð 	9ð 	9ð 	9ð 	9ð 	9øøøð 	9ð 	9ð 	9ð 	9ð 	9ð 	9s   ½3A=Á=BÂBc                 óâ  — t          j        ¦   «         }	 t          j        t          j                             |d¦  «        ¦  «         t          j                             |dd¦  «        }t          |d¦  «        5 }|                     d¦  «         ddd¦  «         n# 1 swxY w Y   t          j                             |d¦  «        }t          |d¦  «        5 }|                     d¦  «         ddd¦  «         n# 1 swxY w Y   g }t          |¦  «        }t          |g|¦  «        }|  
                    |d¦  «         |  
                    t          |¦  «        t          d	t          t          |t          d
¦  «        d¦  «        ¦  «        fd	t          t          |t          d
¦  «        d¦  «        ¦  «        fg¦  «        ¦  «         t          j        |¦  «         dS # t          j        |¦  «         w xY w)zv
        L{checkRecursive} descends into each directory, finding Python files
        and reporting problems.
        rr   zbar.pyr¸   s   import baz
Nzbaz.pys   import contrabandé   rC   rÖ   ÚbazÚ
contraband)rS   rT   r,   rv   r_   r`   ra   r…   r?   r	   rg   rw   rE   r   r   rY   rZ   )r   rU   Úfile1r‡   Úfile2rA   r    Úwarningss           r   Útest_checkRecursivezCheckTests.test_checkRecursive|  s3  € õ
 Ô"Ñ$Ô$ˆð	#ÝŒH•R”W—\’\ '¨5Ñ1Ô1Ñ2Ô2Ð2Ý”G—L’L ¨%°Ñ:Ô:ˆEÝ�e˜TÑ"Ô"ð * bØ—’˜Ñ)Ô)Ð)ð*ð *ð *ñ *ô *ð *ð *ð *ð *ð *ð *øøøð *ð *ð *ð *å”G—L’L ¨(Ñ3Ô3ˆEÝ�e˜TÑ"Ô"ð / bØ—’Ð-Ñ.Ô.Ð.ð/ð /ð /ñ /ô /ð /ð /ð /ð /ð /ð /øøøð /ð /ð /ð /àˆCÝ& sÑ+Ô+ˆHÝ% w i°Ñ:Ô:ˆHØ×Ò˜X qÑ)Ô)Ð)Ø×ÒÝ�s‘”Ý˜¥#¥l°5½$¸q¹'¼'À5Ñ&IÔ&IÑ"JÔ"JÐKØ Ý�\¨%µ°a±´¸,ÑGÔGÑHÔHðJðKñ Lô LñMô Mð Mõ ŒM˜'Ñ"Ô"Ð"Ð"Ð"ø�FŒM˜'Ñ"Ô"Ð"Ð"øøøsU   •A#G Á8BÂG ÂBÂG Â!BÂ"3G ÃC7Ã+G Ã7C;Ã;G Ã>C;Ã?CG ÇG.c                 ó\  — d}t          j        ¦   «         }t          |t          |d¦  «        }|                      |d¦  «         |                     ¦   «                              d¦  «        dd…         }t          j        dk    rg d¢}nt          rg d	¢}nd
g}|                      ||¦  «         dS )z;
        L{check} reports syntax errors from stdin
        z-max(1 for i in range(10), key=lambda x: x+1)
r¥   rÖ   r©   Nrª   rö   )ú7<stdin>:1:5: Generator expression must be parenthesizedú,max(1 for i in range(10), key=lambda x: x+1)z    ^)zL<stdin>:1:4: Generator expression must be parenthesized if not sole argumentr,  z   ^r+  )
r*   r+   r   r   rg   r:   Úsplitr   rä   r   )r   rÜ   rŸ   rÅ   ÚerrlinesÚexpected_errors         r   Útest_stdinReportsErrorsz"CheckTests.test_stdinReportsErrors–  sË   € ð BˆÝŒk‰mŒmˆÝ˜S¥%¨°Ñ;Ô;ˆØ×Ò˜ Ñ"Ô"Ð"Ø—<’<‘>”>×'Ò'¨Ñ-Ô-¨c¨r¨cÔ2ˆåÔ˜vÒ%Ð%ðð ð ˆNˆNõ
 ð 		ðð ð ˆNˆNð JðˆNð 	×Ò˜ >Ñ2Ô2Ð2Ð2Ð2r   N)r   r    r!   r"   Ú
contextlibÚcontextmanagerrÂ   rÆ   rÈ   rÎ   rÒ   rØ   ré   rð   ró   rú   r   r  r   r   Úplatformr  r  r  r  r  r!  r)  r0  r#   r   r   r¶   r¶   5  sŒ  € € € € € ðð ð Ôðð ñ Ôðð
Kð 
Kð 
Kðð ð ð<ð <ð <ð,ð ,ð ,ðKð Kð Kð/:ð /:ð /:ðb9ð 9ð 9ð2ð ð ð!ð !ð !ðF:ð :ð :ð8.ð .ð .ð6 €VˆCŒL˜GÒ#Ð%=Ñ>Ô>ðHð Hñ ?Ô>ðHð 	Tð 	Tð 	Tð
1ð 
1ð 
1ð1ð 1ð 1ðyð yð yð9ð 9ð 9ð$#ð #ð #ð43ð 3ð 3ð 3ð 3r   r¶   c                   óJ   — e Zd ZdZd„ Zd„ Zd„ Zdd„Zd„ Zd„ Z	d	„ Z
d
„ Zd„ ZdS )ÚIntegrationTestszF
    Tests of the pyflakes script that actually spawn the script.
    c                 óŠ   — t          j        ¦   «         | _        t          j                             | j        d¦  «        | _        d S )NÚtemp)rS   rT   rU   r,   r_   r`   Útempfilepathr7   s    r   rV   zIntegrationTests.setUp¸  s2   € ÝÔ'Ñ)Ô)ˆŒÝœGŸLšL¨¬°vÑ>Ô>ˆÔÐÐr   c                 ó8   — t          j        | j        ¦  «         d S r   rX   r7   s    r   r[   zIntegrationTests.tearDown¼  r\   r   c                 ó–   — ddl }t          j                             |j        ¦  «        }t          j                             |ddd¦  «        S )z9
        Return the path to the pyflakes binary.
        r   Nz..ÚbinrÊ   )rÊ   r,   r_   ÚdirnameÚ__file__r`   )r   rÊ   Úpackage_dirs      r   ÚgetPyflakesBinaryz"IntegrationTests.getPyflakesBinary¿  s=   € ð 	ˆˆˆÝ”g—o’o hÔ&7Ñ8Ô8ˆÝŒw�|Š|˜K¨¨u°jÑAÔAÐAr   Nc                 óÌ  — t          t          j        ¦  «        }t          j                             t
          j        ¦  «        |d<   t
          j        |                      ¦   «         g}| 	                    |¦  «         |rct          j        ||t          j        t          j        t          j        ¬¦  «        }|                     |                     d¦  «        ¦  «        \  }}nCt          j        ||t          j        t          j        ¬¦  «        }|                     ¦   «         \  }}|                     ¦   «         }|                     d¦  «        }|                     d¦  «        }|||fS )a	  
        Launch a subprocess running C{pyflakes}.

        @param paths: Command-line arguments to pass to pyflakes.
        @param stdin: Text to use as stdin.
        @return: C{(returncode, stdout, stderr)} of the completed pyflakes
            process.
        Ú
PYTHONPATH)Úenvr/   r2   r   rº   )rB  r2   r   r  )Údictr,   ÚenvironÚpathsepr`   r   r_   Ú
executabler?  ÚextendÚ
subprocessÚPopenÚPIPEÚcommunicater¾   Úwaitr¹   )	r   Úpathsr/   rB  ÚcommandÚpr2   r   Úrvs	            r   ÚrunPyflakeszIntegrationTests.runPyflakesÇ  s#  € õ •2”:ÑÔˆÝœJŸOšO­C¬HÑ5Ô5ˆˆLÑÝ”> 4×#9Ò#9Ñ#;Ô#;Ð<ˆØ�Š�uÑÔÐØð 	/ÝÔ  ¨c½¼Ý(2¬Å
ÄðQñ Qô QˆAà Ÿ}š}¨U¯\ª\¸'Ñ-BÔ-BÑCÔCÑˆV�V�VåÔ  ¨cÝ(2¬Å
ÄðQñ Qô QˆAà Ÿ}š}™œÑˆV�VØ�VŠV‰XŒXˆØ—’˜wÑ'Ô'ˆØ—’˜wÑ'Ô'ˆØ˜ Ð#Ð#r   c                 ó¶   — t          | j        d¦  «                             ¦   «          |                      | j        g¦  «        }|                      |d¦  «         dS )z�
        When a Python source file is all good, the return code is zero and no
        messages are printed to either stdout or stderr.
        r^   )r'   r'   r   N)ra   r8  rb   rQ  rg   )r   Úds     r   Útest_goodFilezIntegrationTests.test_goodFileá  sX   € õ
 	ˆTÔ Ñ$Ô$×*Ò*Ñ,Ô,Ð,Ø×Ò˜dÔ/Ð0Ñ1Ô1ˆØ×Ò˜˜KÑ(Ô(Ð(Ð(Ð(r   c                 óT  — t          | j        d¦  «        5 }|                     d¦  «         ddd¦  «         n# 1 swxY w Y   |                      | j        g¦  «        }t	          | j        t          d¦  «        d¦  «        }|                      ||› t          j        › �ddf¦  «         dS )z…
        When a Python source file has warnings, the return code is non-zero
        and the warnings are printed to stdout.
        r¸   s   import contraband
NrÖ   r%  r'   )	ra   r8  r…   rQ  r   r   rg   r,   r-   )r   r‡   rS  rï   s       r   Útest_fileWithFlakesz$IntegrationTests.test_fileWithFlakesê  sß   € õ
 �$Ô# TÑ*Ô*ð 	-¨bØ�HŠHÐ+Ñ,Ô,Ð,ð	-ð 	-ð 	-ñ 	-ô 	-ð 	-ð 	-ð 	-ð 	-ð 	-ð 	-øøøð 	-ð 	-ð 	-ð 	-à×Ò˜dÔ/Ð0Ñ1Ô1ˆÝ Ô 1µ4¸±7´7¸LÑIÔIˆØ×Ò˜ Ð6­"¬*Ð6Ð6¸¸AÐ>Ñ?Ô?Ð?Ð?Ð?ó   –8¸<¿<c                 ó¸   — |                       | j        g¦  «        }d                     | j        t          j        ¦  «        }|                      |d|df¦  «         dS )úº
        When pyflakes finds errors with the files it's given, (if they don't
        exist, say), then the return code is non-zero and the errors are
        printed to stderr.
        z{}: No such file or directory{}r'   rÖ   N)rQ  r8  rí   r,   r-   rg   )r   rS  Ú	error_msgs      r   Útest_errors_iozIntegrationTests.test_errors_ioõ  sa   € ð ×Ò˜dÔ/Ð0Ñ1Ô1ˆØ5×<Ò<¸TÔ=NÝ=?¼ZñIô Iˆ	à×Ò˜˜R ¨AÐ.Ñ/Ô/Ð/Ð/Ð/r   c                 ó<  — t          | j        d¦  «        5 }|                     d¦  «         ddd¦  «         n# 1 swxY w Y   |                      | j        g¦  «        }d                     | j        t
          j        ¦  «        }|                      |d|df¦  «         dS )rY  r¸   s   importNz-{0}:1:7: invalid syntax{1}import{1}      ^{1}r'   rÖ   )ra   r8  r…   rQ  rí   r,   r-   rg   )r   r‡   rS  rZ  s       r   Útest_errors_syntaxz#IntegrationTests.test_errors_syntax   sÖ   € õ �$Ô# TÑ*Ô*ð 	 ¨bØ�HŠH�YÑÔÐð	 ð 	 ð 	 ñ 	 ô 	 ð 	 ð 	 ð 	 ð 	 ð 	 ð 	 øøøð 	 ð 	 ð 	 ð 	 à×Ò˜dÔ/Ð0Ñ1Ô1ˆØC×JÒJØÔ�rœzñ+ô +ˆ	à×Ò˜˜R ¨AÐ.Ñ/Ô/Ð/Ð/Ð/rW  c                 ó¾   — |                       g d¬¦  «        }t          dt          d¦  «        d¦  «        }|                      ||› t          j        › �ddf¦  «         dS )zU
        If no arguments are passed to C{pyflakes} then it reads from stdin.
        zimport contraband)r/   r¥   rÖ   r%  r'   N)rQ  r   r   rg   r,   r-   )r   rS  rï   s      r   Útest_readFromStdinz#IntegrationTests.test_readFromStdin  sd   € ð ×Ò˜RÐ':ÐÑ;Ô;ˆÝ 	­4°©7¬7°LÑAÔAˆØ×Ò˜ Ð6­"¬*Ð6Ð6¸¸AÐ>Ñ?Ô?Ð?Ð?Ð?r   r   )r   r    r!   r"   rV   r[   r?  rQ  rT  rV  r[  r]  r_  r#   r   r   r5  r5  ´  sµ   € € € € € ðð ð?ð ?ð ?ð$ð $ð $ðBð Bð Bð$ð $ð $ð $ð4)ð )ð )ð	@ð 	@ð 	@ð	0ð 	0ð 	0ð0ð 0ð 0ð@ð @ð @ð @ð @r   r5  c                   ó   — e Zd ZdZdd„ZdS )ÚTestMainz.
    Tests of the pyflakes main function.
    Nc                 óD  — 	 t          |¦  «        5 }t          |¬¦  «         d d d ¦  «         n# 1 swxY w Y   t          d¦  «        ‚# t          $ rM}|                      |j        t          ¦  «         t          |j        ¦  «        }|j        |j	        |fcY d }~S d }~ww xY w)N)r   zSystemExit not raised)
r%   r   ÚRuntimeErrorÚ
SystemExitÚassertIsInstanceÚcodeÚboolÚintr;   r<   )r   rM  r/   Úcapturer€   rP  s         r   rQ  zTestMain.runPyflakes  sï   € ð	8Ý# EÑ*Ô*ð !¨gÝ˜%Ð Ñ Ô Ð ð!ð !ð !ñ !ô !ð !ð !ð !ð !ð !ð !øøøð !ð !ð !ð !õ Ð6Ñ7Ô7Ð7øõ ð 	7ð 	7ð 	7Ø×!Ò! !¤&­$Ñ/Ô/Ð/Ý�Q”V‘”ˆBØ”N G¤M°2Ð6Ð6Ð6Ð6Ð6Ð6Ð6øøøøð	7øøøs9   ‚A ‘.¢A ®2²A µ2¶A Á
BÁABÂBÂBr   )r   r    r!   r"   rQ  r#   r   r   ra  ra    s2   € € € € € ðð ð	8ð 	8ð 	8ð 	8ð 	8ð 	8r   ra  ) r"   r1  r*   r,   r   rY   rH  rS   Úpyflakes.checkerr   Úpyflakes.messagesr   Úpyflakes.reporterr   Úpyflakes.apir   r   r   r	   r
   Úpyflakes.test.harnessr   r   r   r   r%   r?   rQ   r—   r¶   r5  ra  r#   r   r   ú<module>ro     s„  ððð ð Ð Ð Ð Ø 	€	€	€	Ø 	€	€	€	Ø 
€
€
€
Ø €€€Ø Ð Ð Ð Ø €€€à !Ð !Ð !Ð !Ð !Ð !Ø *Ð *Ð *Ð *Ð *Ð *Ø &Ð &Ð &Ð &Ð &Ð &ðð ð ð ð ð ð ð ð ð ð ð ð ð ð 3Ð 2Ð 2Ð 2Ð 2Ð 2Ð 2Ð 2ðð ð ð%ð %ð %ð %ð %ñ %ô %ð %ð'ð 'ð 'ð 'ð 'ñ 'ô 'ð 'ð:Nð Nð Nð Nð Nñ Nô Nð Nð.y"ð y"ð y"ð y"ð y"˜ñ y"ô y"ð y"ðxT9ð T9ð T9ð T9ð T9�8ñ T9ô T9ð T9ðn|3ð |3ð |3ð |3ð |3�ñ |3ô |3ð |3ð~_@ð _@ð _@ð _@ð _@�xñ _@ô _@ð _@ðD8ð 8ð 8ð 8ð 8Ðñ 8ô 8ð 8ð 8ð 8r   