
    eL                        d dl mZ d dlZd dlmZ d dlmZ d dlmZ dZ		 h dZ
	 h dZ	 e	f	 	 	 	 	 dd	Z	 	 	 	 	 	 dd
Zy)    )annotationsN)Iterator)Path)FunctionalTestFile1   >   ext
regressionregression_02deprecated_relative_import>   r   	docparamsr   c                H   g }t        t        |       |       t        j                  |       D ]r  \  }}}|j	                  d      r|j                          |j                          |D ]5  }|dk7  s	|j	                  d      s|j                  t        ||             7 t |S )z*Get all functional tests in the input_dir.__pycache__z__init__.py.py)!_check_functional_tests_structurer   oswalkendswithsortappendr   )	input_dirmax_file_per_directorysuitedirpathdirnames	filenamesfilenames          S/usr/lib/python3/dist-packages/pylint/testutils/functional/find_functional_tests.py(get_functional_test_files_from_directoryr   #   s    
 E%d9o7MN(*	(: D$9M*! 	DH=(X->->u-E/BC	DD L    c                b  
 t        |       j                  j                  d      ryt               }t               }	 	 	 	 	 	 dfd
d
fd |       D ]E  }|j	                         r|j                  |       %|j                  dk(  s5|j                  |       G g }g }|D ]  }|j                  |j                  j                  d      d   z  }|j                         r|j                  ||f       t        |j                  j                        dk(  rt|j                  j                  t        vs|j                  j                  j                  t        vs|j                  j                  |j                  j                        r|j                  |        |s|rd}	|D ]2  \  }}|	d	|  d
|j                  |        d|j                  |        dz  }	4 |D ]A  }|	d	|  d|j                  |        d|j                   d|j                  j                   d	z  }	C t        |	      y)zrCheck if test directories follow correct file/folder structure.

    Ignore underscored directories or files.
    _Nc                    t        d | j                         D              }t        |      kD  r|j                  | t        |      f       |S )zEReturn directories and files from a directory and handles violations.c              3  X   K   | ]"  }|j                   j                  d       r| $ yw)r!   N)stem
startswith).0ps     r   	<genexpr>zQ_check_functional_tests_structure.<locals>._get_files_from_dir.<locals>.<genexpr>H   s&      0
QVV->->s-CA0
s    **)listiterdirlenr   )path
violations files_without_leading_underscorer   s      r   _get_files_from_dirz>_check_functional_tests_structure.<locals>._get_files_from_dirD   sS     ,0 0
||~0
 ,
( /03IItS)I%JKL//r   c           	   3    K   g }t               } | |      }d}|D ]Q  }|j                         r- ||      }|j                          	  |      E d {    @|j                          S |s|r2|}|D ]  \  }	}
|d|	 d|
 d dz  } |D ]  }||z  }	 t        |      y 7 P# t        $ r4}|j	                  t        |      j                  |d             Y d }~d }~ww xY ww)NzBThe following directory contains too many functional tests files:
 z- z: z when the max is 
)setis_dirresolveAssertionErroraddstrreplace)r,   r-   violations_msgsparent_dir_files	error_msg_file_or_dir_filese_msgoffending_filenumberr/   r   r   s              r   r   z/_check_functional_tests_structure.<locals>.walkO   s*    -/
$'E.tZ@Q 	 - 		-L""$,\:F"**,,G#L111 #**,,		- D*4 c&"^,Bvh6GH^G__abbc, "		!" && ) 2% G#''Ay"(EFFGsC   AC*B*B(B*AC*(B**	C'3*C"C*"C''C*r   r      z1The following functional tests are disorganized:
z- In 'z', 'z' should go in 'z'
z', zA should go in a directory that starts with the first letters of 'z' (not 'z')
)r,   r   r-   zlist[tuple[Path, int]]returnz
list[Path])r,   r   rD   zIterator[Path])r   r$   r%   r3   r4   r7   suffixparentsplitexistsr   r+   IGNORED_PARENT_DIRSIGNORED_PARENT_PARENT_DIRSrelative_tor6   )	directoryr   filesdirsfile_or_dirdirectory_does_not_existsmisplaced_filefilepossible_dirmsgr/   r   s    `        @@r   r   r   7   s1    I&&s+uEeD	0	0 6	0		0'4 I #HH[!5(IIk"	# :<!#N ,{{TYY__S%9!%<< %,,dL-AB DKK$$%*  (;;""''/II99''(8(89%%d+, !NB"; 	D,4(8(8(C'D E!!-!9!9)!D ESJC	
 # 	D3t'7'7	'B&C D		{(4;;+;+;*<DBC	 S!! %3r   )r   z
Path | strr   intrD   zlist[FunctionalTestFile])rL   r   r   rU   rD   None)
__future__r   r   collections.abcr   pathlibr   %pylint.testutils.functional.test_filer   !REASONABLY_DISPLAYABLE_VERTICALLYrI   rJ   r   r    r   r   <module>r]      s   
 # 	 $  D$& !
  8 
 C
 #D (T"T"-0T"	T"r   