
    i                          d dl m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	 e
j                  ej                  d      d    dz   Zd Zd Zd Zd	 Zd
 ZddZy)    )print_functionN)PY3   z/datac                    t        | t              s| g} g }| D ]k  }t        |t              st        |      }t	        |      D ]@  }||   }t        |t
        j                        s#t        |d      s0|j                  |       B m |S )Nunittest)	
isinstancelistdictvarssortedtypesFunctionTypehasattrappend)collections	functions
collectionkeyvalues        w/var/www/vps2.regionflexible.com/Desarrollo/venv/lib/python3.12/site-packages/srsly/tests/ruamel_yaml/test_appliance.pyfind_test_functionsr      s    k4("mI! (
*d+j)J*% 	(CsOE%!3!34
9S  '	((     c                    i }t        j                  |       D ]  }t         j                  j                  t         j                  j	                  | |            sAt         j                  j                  |      \  }}|j                  t        rdnd      r}|j                  |g       j                  |        t        |j                               }|S )Nz-py2z-py3)oslistdirpathisfilejoinsplitextendswithr   
setdefaultr   r   items)	directory	filenamesfilenamebaseexts        r   find_test_filenamesr(       s    IJJy) 777>>"'',,y(;<((2ID#}}sV7  r*11#67 y()Ir   c                    t        j                  d      }|j                  ddddt        j                  v d       |j                  d	dd
       |j                  ddd       |j                  ddd       |j                  |       } | j                  }| j                  r| j                  gng }| j                  }dt        j                  v r0|j                  t        j                  d   j                                dt        j                  v r0|j                  t        j                  d   j                                |||| fS ) a   run the yaml tests. By default
    all functions on all appropriate test_files are run. Functions have
    unittest attributes that determine the required extensions to filenames
    that need to be available in order to run that test. E.g.


    python test_yaml.py test_constructor_types

    python test_yaml.py --verbose test_tokens spec-02-05


    The presence of an extension in the .skip attribute of a function
    disables the test for that function.)usagez	--verbosez-v
store_trueYAML_TEST_VERBOSEzset verbosity output)actiondefaulthelpz--list-functionszHlist all functions with required file extensions for test files
        )r.   r0   function?zrestrict function to run)nargsr0   r$   *zbasename of filename set, extensions (.code, .data) have to
        be a superset of those in the unittest attribute of the selected
        functionYAML_TEST_FUNCTIONSYAML_TEST_FILENAMES)argparseArgumentParseradd_argumentr   environ
parse_argsverboser1   r$   extendsplit)argsparserr<   include_functionsinclude_filenamess        r   parse_argumentsrC   ,   sA   $$,	F #rzz1#      
#4RS
   T"DllG+/==b 

*  ,A!B!H!H!JK 

*  ,A!B!H!H!JK/$>>r   c                    t         r| j                  }n%t        | d      r| j                  }n| j                  }|rSt
        j                  j                  d       t
        j                  j                  |ddj                  |      d       	  | |d|i d}d }|s t
        j                  j                  d       	 t
        j                  j                          ||||fS # t        $ r}t        j                         }t        |t              rd	}nd
}|r&t        j                  dt
        j                         n@t
        j                  j                  |d          t
        j                  j                          Y d }~d }~ww xY w)Nunittest_nameL===========================================================================
(, z)...
r<   SUCCESS.FAILUREERROR   )limitfiler   )r   __name__r   rE   	func_namesysstdoutwriter   	Exceptionexc_infor   AssertionError	traceback	print_excflush)r1   r$   r<   namekindinfoexcs          r   executer_   j   s&   
  8_-))D%%D

)

$		)0DEF"9-- JJS!JJ)T4((#  
||~c>*DDacjj9JJT!W%JJ
s   C! !	F*BF  Fc           	      l   | r!|st         j                  j                  d       t        |       }d}d}| D ]T  \  }}}}|dk(  r|dk(  r|dz  }|dk(  r|dz  }t         j                  j                  d       t         j                  j                  |dd	j	                  |      d
|d       |dk(  r$t        j                  |dt         j                  i nt         j                  j                  d       t        j                  |d   t         j                         t         j                  j                  d|d   j                  z         t         j                  j                  d       |d   j                  D ]'  }	t        j                  |	t         j                         ) |D ]  }
t         j                  j                  d       t         j                  j                  d|
z         t        r(t        |
dd      5 }|j                         }d d d        n%t        |
d      5 }|j                         }d d d        t         j                  j                         |s|d   dk7  st         j                  j                  d        W t         j                  j                  d       t         j                  j                  d|z         d}|r$t         j                  j                  d|z         d}|r$t         j                  j                  d|z         d}|S # 1 sw Y   xY w# 1 sw Y   xY w)N
r   rI   rK   rM   rL   rF   rG   rH   z): rO   z#Traceback (most recent call last):
r   )rO   z%s: see below
zL~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
)streamzL---------------------------------------------------------------------------
z%s:
rreplace)errorsrbz
TESTS: %s
zFAILURES: %s
zERRORS: %s
)rR   rS   rT   lenr   rX   print_exceptionprint_tbrP   r?   pprintr   openread)resultsr<   totalfailuresre   r[   r$   r\   r]   argr%   fpdataret_vals                 r   displayru      s   w

LEHF'. '#it99MH7?aKF

)

491EtLM7?%%=3::=JJCDtAwSZZ8JJ.a1A1AABJJ_-Aw|| 6c#**56! 	'HJJ_-JJWx/0(C	: %b779D% % (D) %R779D%JJT"RD(

  &	'%'< JJ_%JJ]U*+G

)H45

&01N#% %% %s   ?L%L*L'*L3c           
         t        |       }t        t              }t        |      \  }}}}|j                  rBt        d       |D ]1  }t        dj                  |j                  |j                               3 y g }	|D ]  }
|r|
j                  |vr|
j                  r|D ]  \  }}|r||vrg }|
j                  D ]>  }||vr $|j                  t        j                  j                  t        ||z                @ t        |
dg       }|D ]  }||v s u t        |
||      }|	j                  |        t        |
g |      }|	j                  |        t        |	|      S )Nztest functions:z  {:30s} {}skip)r<   )r   r(   DATArC   list_functionsprintformatrP   r   r   r   r   r   getattrr_   ru   )r   r?   test_functionstest_filenamesrA   rB   r<   afrn   r1   r&   extsr$   r'   	skip_extsskip_extresults                     r   runr      sv   (5N(.N7Ft7L4('1  	@A-&&qzz1::>?	@G" #!2!2:K!K, /
d$5F)F	#,, /C$$$RWW\\$s
%CD/
 !(&" =I$- /#t+!/ ")9g!Fv./" Xr73FNN6"-#. 7G,,r   )N)
__future__r   rR   r   r   rX   rk   r7   srsly.ruamel_yaml.compatr   __file__rsplitseprx   r   r(   rC   r_   ru   r    r   r   <module>r      s^    % 
 	     ( rvvq!!$w.	;?|)B-`!-r   