B
    u9a              K   @   s  d dl mZmZmZmZmZmZ yd dl mZmZm	Z	 W n e
k
rP   dZ	Y nX d dlZd dlZd dlZd dlmZ e jdkrdd e jdD \ZZZeeefd	k red
dddddddddddddddddddddd d!d"d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1d2d3d4d5d6d7d8d9d:d;d<d=d>d?d@dAdBdCdDdEdFdGdHdIdJdKdLdMdNdOdPdQdRdSdTdUgKadVdW ZdXdYdZd[d\ZG d]d^ d^ejZed_kre  dS )`    )	setlocaleLC_ALLLC_CTYPE
LC_NUMERIC
localeconvError)	RADIXCHARTHOUSEPnl_langinfoN)unameZDarwinc             C   s   g | ]}t |qS  )int).0partr   r   "/usr/lib/python3.7/test__locale.py
<listcomp>   s    r   .)   r   r   z%locale support broken for OS X < 10.4Zes_UYfr_FRfi_FIes_COpt_PTit_ITet_EEes_PYZno_NOnl_NLlv_LVel_GRbe_BYfr_BEro_ROZru_UAru_RUes_VEca_ESse_NOes_ECid_IDka_GEes_CLZwa_BEhu_HUlt_LTsl_SIhr_HRes_ARes_ESoc_FRgl_ESbg_BGis_ISmk_MKde_ATpt_BRda_DKnn_NOcs_CZde_LUes_BOsq_ALsk_SKfr_CHde_DEZsr_YUbr_FRnl_BEsv_FIpl_PLfr_CAfo_FObs_BAfr_LUkl_GLfa_IRZde_BEsv_SEit_CHuk_UAeu_ESvi_VNaf_ZAnb_NOZen_DKtg_TJps_AFen_USzfr_FR.ISO8859-1zfr_FR.UTF-8zfr_FR.ISO8859-15@eurozru_RU.KOI8-Rzko_KR.eucKRc                 s   t jdkrttj} zg }xtD ]}yttj| W n tk
rN   w"Y nX td}y
t  W n: t	k
r } zt
d||t||f  W d d }~X Y q"X || q"W |aW d ttj|  X dt jkrdd   fddtD ad S )	NZsunos5Fz.WARNING: Skip locale %s (encoding %s): [%s] %sz
MSC v.1200c             S   s(   |  d}t|dko$t|d dk S )Nr      	   )splitlen)locar   r   r   accept:   s    
zsetUpModule.<locals>.acceptc                s   g | ]} |r|qS r   r   )r   rX   )rZ   r   r   r   =   s    zsetUpModule.<locals>.<listcomp>)sysplatformlocaler   r   candidate_localesr   getpreferredencodingr   	Exceptionprinttypeappendversion)Z
old_localeZlocalesrX   encodingerrr   )rZ   r   setUpModule   s*    



&
rg   )r   ,)rh   r   )rh    )u   ٫u   ٬)rR   r>   r   rQ   c               @   s`   e Zd Zdd Zdd ZdZdd Zee	dd	d
 Z
dd Zee	ddd Zdd ZdS )_LocaleTestsc             C   s   t t| _d S )N)r   r   	oldlocale)selfr   r   r   setUpM   s    z_LocaleTests.setUpc             C   s   t t| j d S )N)r   r   rk   )rl   r   r   r   tearDownP   s    z_LocaleTests.tearDownz)%s != %s (%s for %s; set to %s, using %s)c             C   sj   yt t}W n tk
r$   d}Y nX t|d|dk }|rf|rf| ||| j||||||f  dS dS )z5Compare calculation against known value, if availablez<not able to determine>)ri   ri   thousands_sepTN)r   r   r   known_numericsgetassertEquallc_numeric_err_msg)rl   Z	calc_typeZ
calc_valueZ	data_typeZused_locale
set_localeZknown_valuer   r   r   numeric_testerX   s    

z_LocaleTests.numeric_testerznl_langinfo is not availablec          	   C   s   d}xrt D ]j}ytt| tt| W n tk
r<   w
Y nX x4tdftdffD ] \}}| dt|||rPd}qPW q
W |s| 	d d S )NFdecimal_pointro   r
   Tzno suitable locales)
r^   r   r   r   r   r   r	   ru   r
   skipTest)rl   testedrX   lilcr   r   r   test_lc_numeric_nl_langinfoh   s    

z(_LocaleTests.test_lc_numeric_nl_langinfoc          	   C   s   d}xht D ]`}ytt| tt| W n tk
r<   w
Y nX t }x$dD ]}| d|| ||rJd}qJW q
W |s|| d d S )NF)rv   ro   r   Tzno suitable locales)r^   r   r   r   r   r   ru   rw   )rl   rx   rX   Z
formattingrz   r   r   r   test_lc_numeric_localeconvy   s    


z'_LocaleTests.test_lc_numeric_localeconvc             C   s   d}xt D ]}ytt| tt| W n tk
r<   w
Y nX xrtdftdffD ]^\}}t|}t | }ytt}W n tk
r   d}Y nX | 	||d||||f  d}qPW q
W |s| 
d d S )NFrv   ro   z<not able to determine>z9%s (nl_langinfo) != %s (localeconv) (set to %s, using %s)Tzno suitable locales)r^   r   r   r   r   r   r	   r
   r   rr   rw   )rl   rx   rX   ry   rz   Znl_radixcharZli_radixcharrt   r   r   r   test_lc_numeric_basic   s,    



z"_LocaleTests.test_lc_numeric_basicc          	   C   s   d}xt D ]}ytt| tt| W n tk
r<   w
Y nX |dkrVt d dkrVq
| ttdd dd|  | tt	dd dd	|  t d d
kr| 
tt	t d ddg d}q
W |s| d d S )NFrL   rv   z' z3.14d   i:  z using eval('3.14') failed for %sz!using float('3.14') failed for %sr   1Z23Tzno suitable locales)r^   r   r   r   r   r   rr   r   evalfloatZassertRaises
ValueErrorjoinrw   )rl   rx   rX   r   r   r   test_float_parsing   s&    



z_LocaleTests.test_float_parsingN)__name__
__module____qualname__rm   rn   rs   ru   unittestZ
skipUnlessr
   r{   r|   r}   r   r   r   r   r   rj   K   s   rj   __main__)_localer   r   r   r   r   r   r   r	   r
   ImportErrorr]   r[   r   r\   r   systemreleaserV   ZmajminZmicZSkipTestr^   rg   rp   ZTestCaserj   r   mainr   r   r   r   <module>   s>    

&u
