HEX
Server: Apache
System: Linux opal14.opalstack.com 3.10.0-1160.108.1.el7.x86_64 #1 SMP Thu Jan 25 16:17:31 UTC 2024 x86_64
User: curbgloabal_opal (1234)
PHP: 8.1.29
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //lib64/python3.6/test/__pycache__/test_strptime.cpython-36.pyc
3


 \G~�@s�dZddlZddlZddlZddlZddlZddlmZddlm	Z
ddlZGdd�dej�Z
Gdd�dej�ZGd	d
�d
ej�ZGdd�dej�ZGd
d�dej�ZGdd�dej�ZGdd�dej�ZGdd�dej�Zedkr�ej�dS)zPyUnit testing against strptime�N)�support)�datec@seZdZdZdd�ZdS)�
getlang_Testsz
Test _getlangcCs|jtj�tjtj��dS)N)�assertEqual�	_strptime�_getlang�locale�	getlocale�LC_TIME)�self�r�%/usr/lib64/python3.6/test_strptime.py�
test_basicszgetlang_Tests.test_basicN)�__name__�
__module__�__qualname__�__doc__rrrrr
r
src@sPeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�ZdS)�LocaleTime_Testsz�Tests for _strptime.LocaleTime.

    All values are lower-cased when stored in LocaleTime, so make sure to
    compare values after running ``lower`` on them.

    cCstj�|_tj�|_dS)z(Create time tuple based on current time.N)�time�	localtime�
time_tupler�
LocaleTime�LT_ins)rrrr
�setUps
zLocaleTime_Tests.setUpcCsNtj||j�j�}||j|}|j||d|�|j||d|||f�dS)z�Helper method that tests testing against directive based on the
        tuple_position of time_tuple.  Uses error_msg as error message.

        z%s: not found in tuplez-%s: position within tuple incorrect; %s != %sN)r�strftimer�lower�assertInr)rZtesting�	directiveZtuple_positionZ	error_msg�strftime_outputZ
comparisonrrr
�compare_against_times
z%LocaleTime_Tests.compare_against_timecCs,|j|jjddd�|j|jjddd�dS)Nz%A�z#Testing of full weekday name failedz%az*Testing of abbreviated weekday name failed)rr�	f_weekday�	a_weekday)rrrr
�test_weekday-szLocaleTime_Tests.test_weekdaycCs,|j|jjddd�|j|jjddd�dS)Nz%B�z&Testing against full month name failedz%bz-Testing against abbreviated month name failed)rrZf_month�a_month)rrrr
�
test_month5szLocaleTime_Tests.test_monthcCsVtjd|j�j�}|j||jjd�|jddkr8d}nd}|j|jj||d�dS)Nz%pz!AM/PM representation not in tuple��rr$z;AM/PM representation in the wrong position within the tuple)rrrrrr�am_pmr)rr�positionrrr
�
test_am_pm=szLocaleTime_Tests.test_am_pmcCsNtjd|j�j�}|rJ|j||jjdkp8||jjdkd||jjf�dS)Nz%Zrr$ztimezone %s not found in %s)rrrr�
assertTruer�timezone)rr-rrr
�
test_timezoneGszLocaleTime_Tests.test_timezonec	Cs�d}tjd
|�}|jtj|jj|�|d�tjd|�}|jtj|jj|�|d
�tjd|�}|jtj|jj|�|d�tj�}d|_	|j
|jd�dS)N��r'���,�7��Lrz%czLC_date_time incorrectz%xzLC_date incorrectz%XzLC_time incorrect�z6LocaleTime's LC directives cannot handle empty strings)	r/r'r0r1r2r3r4r5r)r6r6)rrrrZLC_date_timeZLC_dateZLC_timerrr)r,)rZ
magic_daterZLTrrr
�test_date_timePszLocaleTime_Tests.test_date_timecCs|j|jjtj��dS)N)rr�langrr)rrrr
�	test_langfszLocaleTime_Tests.test_langN)rrrrrrr#r&r+r.r7r9rrrr
rs
	rc@sPeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�ZdS)�TimeRETestszTests for TimeRE.cCstj�|_tj�|_dS)z Construct generic TimeRE object.N)r�TimeRE�time_rer�locale_time)rrrr
ros
zTimeRETests.setUpcCst|jjd�}|j|j|jjd�d	kd|�|j|j|jjd�d
kd|�|j|j|jd�dkd|�dS)Nz%a %A %dr4r$z7did not find abbreviated weekday in pattern string '%s'�z0did not find full weekday in pattern string '%s'�dz.did not find 'd' directive pattern string '%s'���r@r@)r<�patternr,�findr=r"r!)r�pattern_stringrrr
�test_patterntszTimeRETests.test_patterncCs"|jjd�}|jd|d|�dS)Nz\d+z\\d\+z/%s does not have re characters escaped properly)r<rAr)rrCrrr
�test_pattern_escaping�sz!TimeRETests.test_pattern_escapingcCsB|jjd�j|jjd�}|j|o6|jd�|jjdkd�|jjd�}|jd|jjd|jjdf�}|j|d|j	d|jjd|jjdff�|j|jd	�|jjdko�|jd
�|jjdkd|j
|jj	|jd	�|jd
�f�xRd#D]J}|jjd!|�}|jtj
d!|��}|j|d"tj
d!|�|j	f��q�WdS)$Nz%Ar �Azre object for '%A' failedz%a %bz%s %sr>z,Match failed with '%s' regex and '%s' string�a�bzkre object couldn't find the abbreviated weekday month in '%s' using '%s'; group 'a' = '%s', group 'b' = %s'�B�cr?�G�H�I�j�m�M�p�S�u�U�V�w�W�x�X�y�Y�Z�%z(Matching failed on '%s' using '%s' regex)rGrFrHrIrJr?rKrLrMrNrOrPrQrRrSrTrUrVrWrXrYrZr[r\r])r<�compile�matchr=r!r,�groupr"r%rA�string�rerr)r�foundZcompiledrrrr
�test_compile�s,zTimeRETests.test_compilecCs4tj�}t�t�f|_|jtj|�jd�dd�dS)Nz%Zr6z6with timezone == ('',''), TimeRE().pattern('%Z') != '')rr�	frozensetr-rr;rA)rZtest_localerrr
�test_blankpattern�szTimeRETests.test_blankpatterncCs&|jjd�}|jd�}|j|d�dS)Nz\w+ %mz\w+ 10z"Escaping failed of format '\w+ 10')r<r^r_r,)rZcompiled_rercrrr
�test_matching_with_escapes�s
z&TimeRETests.test_matching_with_escapescCs@tj�}td�td�f|_tj|�}|j|jd�jd�d�dS)N�utc�gmt�Tokyo (standard time)zTokyo (daylight time)z%ZzFlocale data that contains regex metacharacters is not properly escaped)rhrirj)rrrer-r;r,r^r_)rr=r<rrr
�'test_locale_data_w_regex_metacharacters�s
z3TimeRETests.test_locale_data_w_regex_metacharacterscCs4|jjd�}|jtj|d��|jtj|d��dS)Nz%j %HZ180z18 0)r<rAZassertFalserbr_r,)rrArrr
�test_whitespace_substitution�sz(TimeRETests.test_whitespace_substitutionN)rrrrrrDrErdrfrgrkrlrrrr
r:ls

r:c@s�eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�Zd2d3�Zd4S)5�
StrptimeTestszTests for _strptime.strptime.cCstj�|_dS)zCreate testing time tuple.N)r�gmtimer)rrrr
r�szStrptimeTests.setUpcCsP|jttjddd�xxdD]p}ytjd|�WnLtk
rDwYqtk
rz}z|jd||jjf�WYdd}~XqX|jd	|�qW|jt��tjd
d�WdQRX|jt��tjdd
�WdQRXx4dD],}|jt��tjddj|��WdQRXq�W|jt��tjdd�WdQRX|jt��tjdd�WdQRXdS)Nz%dz%A)Zdata_string�formatr]�% �%e�2005z'%s' raised %s, not ValueErrorz'%s' did not raise ValueErrorz1999 50z%Y %Vz1999 51z%G %VrFrGrVrSz%G %{}Z2015z%Gz1999 256z%G %j)r]rprq)rFrGrVrS)	�assertRaises�
ValueErrorr�_strptime_time�	ExceptionZfail�	__class__rro)rZ
bad_format�errrVrrr
�test_ValueError�s,
"
 zStrptimeTests.test_ValueErrorcCsh|jt��}tjdd�WdQRX|j|jjd�|jt��}tjdd�WdQRX|j|jjd�dS)Nr6z%DTZ19z%Y %)rsrtrruZassertIsZ	exception�__suppress_context__)r�errr
�test_strptime_exception_context�sz-StrptimeTests.test_strptime_exception_contextcCs|jttjdd�dS)Nz10 12z%m)rsrtrru)rrrr
�test_unconverteddata�sz"StrptimeTests.test_unconverteddatacCsVtjd||j�}tj|d|�}|j|||j|kd|||||j|f�dS)zHelper fxn in testing.r]z2testing of '%s' directive failed; '%s' -> %s != %sN)rrrrrur,)rrr*�strf_output�strp_outputrrr
�helper�s
zStrptimeTests.helpercCsvxdD]}|j|d�qWxVdD]N\}}xD|D]<}tj|d
�}|t|�}|j|d|kd||df�q.Wq WdS)NrZr[r�l�69�99���00�68z%yz1'y' test failed; passed in '%s' and returned '%s')rZr[�r�r��r�r��r�r��r�r�)r�r�)r�rru�intr,)rrZcenturyZboundsZboundrZexpected_resultrrr
�	test_years

zStrptimeTests.test_yearcCsxdD]}|j|d�qWdS)NrIrHrOr$)rIrHrO)r�)rrrrr
r&s
zStrptimeTests.test_monthcCs|jdd�dS)Nr?r4)r�)rrrr
�test_dayszStrptimeTests.test_daycCsX|jdd�tjd|j�}tj|d�}|j|d|jdkd||d|jdf�dS)NrLr'z%I %pz7testing of '%%I %%p' directive failed; '%s' -> %s != %s)r�rrrrrur,)rr~rrrr
�	test_hourszStrptimeTests.test_hourcCs|jdd�dS)NrPr>)r�)rrrr
�test_minute'szStrptimeTests.test_minutecCs|jdd�dS)NrR�)r�)rrrr
�test_second+szStrptimeTests.test_secondcCsFddl}|jddddddd�}tjt|�dd	�\}}|j||j�dS)
Nri�r(��"�8i�4z%Y-%m-%d %H:%M:%S.%f)ro)�datetimer�strrZmicrosecond)rr�r?�tupZfracrrr
�
test_fraction/szStrptimeTests.test_fractioncCsxdD]}|j|d�qWdS)NrFrGrVrSr )rFrGrVrS)r�)rrrrr
r#6s
zStrptimeTests.test_weekdaycCs|jdd�dS)NrN�)r�)rrrr
�test_julian;szStrptimeTests.test_juliancCs�tjdd�}|j|jd�tjdd�}|j|jd�tj�}tjd�}tj|d�}tj�}tjdtjdksvtj	r�|j
|d|dkd||d|df�n|j
|dd	kd�dS)
N�UTCz%Zr�GMTr$�z'timezone check failed; '%s' -> %s != %sz]LocaleTime().timezone has duplicate values and time.daylight but timezone value not set to -1r@)rrur�tm_isdstrrrr�tzname�daylightr,)rrrr~r=rrr
r.?s
zStrptimeTests.test_timezonecCs�tjd}|j�dkr |jd�tjtd||f��|tjtdd��btjtdd	d
���D||ft_dt_tj|d�d}|j	|dd
tj|tj|f�WdQRXWdQRXWdQRXdS)Nrr�r�zneed non-UTC/GMT timezoner�r�r$�tzsetcSsdS)Nrrrrr
�<lambda>^sz1StrptimeTests.test_bad_timezone.<locals>.<lambda>z%Zr�z^%s lead to a timezone value of %s instead of -1 when time.daylight set to %s and passing in %s)r�r�r@)
rr��upper�skipTestrZ	swap_attrr�rrur)rZtz_nameZtz_valuerrr
�test_bad_timezoneUs


zStrptimeTests.test_bad_timezonecCs"xtd�D]}|jd|�q
WdS)Nr rJ)�ranger�)rr*rrr
r7gszStrptimeTests.test_date_timecCs$xtdd�D]}|jd|�qWdS)Nrr'rX)r�r�)rr*rrr
�	test_datelszStrptimeTests.test_datecCs$xtdd�D]}|jd|�qWdS)Nr'r rY)r�r�)rr*rrr
�	test_timeqszStrptimeTests.test_timecCsJtjd|j�}tj|d�}|j|d|jdko@|d|jdkd�dS)Nz%m %% %Yrr$zhandling of percent sign failed)rrrrrur,)rr~rrrr
�test_percentvs
zStrptimeTests.test_percentcCsZtjd|j�}|jtj|j�d�d�|jtj|j�d�d�|jtj|j�d�d�dS)Nz%Bz0strptime does not handle ALL-CAPS names properlyz1strptime does not handle lowercase names properlyz/strptime does not handle capword names properly)	rrrr,rrur�r�
capitalize)rr~rrr
�test_caseinsensitive~sz"StrptimeTests.test_caseinsensitivec	Cs,d}tjdd�}|j||kd||f�dS)	N�lr$r�1z%mz5Default values for strptime() are incorrect; %s != %sr@)	r�r$r$rrrrr$r@)rrur,)rZdefaultsrrrr
�
test_defaults�s

zStrptimeTests.test_defaultscCsd}|jtj||��dS)Nz.^$*+?{}\[]|)()r,rru)rZ
need_escapingrrr
�
test_escaping�szStrptimeTests.test_escapingcCstjdd�dS)NzFeb 29z%b %d)r�strptime)rrrr
�$test_feb29_on_leap_year_without_year�sz2StrptimeTests.test_feb29_on_leap_year_without_yearcCs |jtjdd�tjdd��dS)NzFeb 29z%b %dzMar 1)Z
assertLessrr�)rrrr
�7test_mar1_comes_after_feb29_even_when_omitting_the_year�s
zEStrptimeTests.test_mar1_comes_after_feb29_even_when_omitting_the_yearN)rrrrrryr|r}r�r�r&r�r�r�r�r�r#r�r.r�r7r�r�r�r�r�r�r�r�rrrr
rm�s4#
	
	
	rmc@seZdZdZdd�ZdS)�Strptime12AMPMTestsz9Test a _strptime regression in '%I %p' at 12 noon (12 PM)cCsb|j}|tjdd�dd�|tjdd�dd�|tjdd�dd�|tjdd�dd�dS)Nz12 PMz%I %pr'r(z12 AMr)rrr�rru)r�eqrrr
�test_twelve_noon_midnight�s
z-Strptime12AMPMTests.test_twelve_noon_midnightN)rrrrr�rrrr
r��sr�c@seZdZdZdd�ZdS)�JulianTestsz@Test a _strptime regression that all julian (1-366) are acceptedcCs8|j}x,tdd�D]}|tjd|d�d|�qWdS)Nr$ioz%d 2004z%j %Yr�)rr�rru)rr��irrr
�test_all_julian_days�sz JulianTests.test_all_julian_daysN)rrrrr�rrrr
r��sr�c@sXeZdZdZdd�Zdd�Zdd�Zdd	�Zej	r<dZ
dZnfZ
fZdd�Zdd�Z
dS)�CalculationTestsz4Test that strptime() fills in missing info correctlycCstj�|_dS)N)rrnr)rrrr
r�szCalculationTests.setUpcCsBd}tjtj||j�|�}|j|j|jjkd|j|jjf�dS)Nz%Y %m %d %H %M %S %w %Zz'Calculation of tm_yday failed; %s != %s)rrurrrr,Ztm_yday)r�
format_string�resultrrr
�test_julian_calculation�sz(CalculationTests.test_julian_calculationc	Csrd}tjtj||j�|�}|j|j|jjkoF|j|jjkoF|j|jjkd|j|j|j|jj|jj|jjf�dS)Nz%Y %H %M %S %w %j %Zz:Calculation of Gregorian date failed; %s-%s-%s != %s-%s-%s)	rrurrrr,Ztm_yearZtm_monZtm_mday)rr�r�rrr
�test_gregorian_calculation�sz+CalculationTests.test_gregorian_calculationcCsBd}tjtj||j�|�}|j|j|jjkd|j|jjf�dS)Nz%Y %m %d %H %S %j %Zz/Calculation of day of the week failed; %s != %s)rrurrrr,Ztm_wday)rr�r�rrr
�test_day_of_week_calculation�sz-CalculationTests.test_day_of_week_calculation�qr$�rr(�����}�%G %Vcs��fdd�}|d.d�|d/d�|d0d
�|d1d�|d2d�|d3d�|d4d�|d5d�|d6d�|d7d�|d8d�|d9d�|d:d�|d;d"�|d<d%�|d=d&�|d>d(�|d?d)�|d@d+�|dAd-�dS)BNc	s�x�d
D]�}|�jkr"|�jkr"dSx�dD]z}|d|}�j|||d	��Tt|�}|j|�}tj||�}d
||d|j�df}�j|dd�||�WdQRXq(WqWdS)N�%Y %W�%Y %U�%G %V�%w�%u�%a�%A� )rroz%r: %s != %sr�r')r�r�r�)r�r�r�r�)	�_formats_excluded�
_ymd_excludedZsubTest�
datetime_daterrruZ	timetupler)	Z	ymd_tupleZtest_reasonZyear_week_formatZweekday_formatr�Zdt_dateZ
strp_inputr�msg)rrr
�test_helper�s"





zSCalculationTests.test_week_of_year_and_day_of_week_calculation.<locals>.test_helper�mr$r'zweek 0r�zcommon case�
z
day on Sunday�z
day on Monday�qzJan 1 on Sunday�rzJan 1 on Mondayr�z)first Sunday in a year starting on Mondayr(r�zDec 31 on SundayzDec 31 on Monday��r�z#Monday in the last week of the yearr1z-Monday in the second-to-last week of the year��
�zrandomly chosen date���zEyear starting and ending on Monday while date not on Sunday or Monday�}r0zXyear starting and ending on Monday with a Monday not at the beginning or end of the yearz8Dec 31 on Monday with year starting and ending on Monday��zFirst Sunday of 2007zSecond Sunday of 2007��zLast Sunday of 2006�zSecond to last Sunday of 2006)r�r$r')r�r$r�)r�r$r�)r�r$r�)r�r$r$)r�r$r$)r�r$r�)r�r(r�)r�r(r�)r�r(r�)r�r(r1)r�r�r�)r�r(r�)r�r�r�)r�r(r0)r�r(r�)r�r$r�)r�r$r�)r�r(r�)r�r(r�r)rr�r)rr
�-test_week_of_year_and_day_of_week_calculation�s*


















z>CalculationTests.test_week_of_year_and_day_of_week_calculationcsT�fdd�}|ddddddddd	d
�
|dddd
ddddd	d�
|dddddddddd�
|dddddddddd�
|dddddddddd�
|ddddddddd
d�
|ddddddddd
d�
|ddddddddd
d�
|dddddddddd�
|dddddddddd�
|dddddddddd�
|dddd
d
ddddd
�
|dddd
d
ddddd
�
|dddd
d
ddddd
�
|d ddd
dddddd�
|d!ddd
dddddd�
|d!ddd
dddddd�
|d"ddd
ddddd#d�
|d$ddd
ddddd#d�
|d$ddd
ddddd#d�
|d%ddd
ddddd	d�
|d&dd'dddddd	d�
|d&dd(d
ddddd	d�
|d)dd'ddddddd�
|d*dd'ddddddd�
|d*dd'ddddddd�
|d+dd'dddddd
d�
|d,dd'dddddd
d�
|d,dd'dddddd
d�
|d-dd'ddddddd.�
|d/dd'ddddddd.�
|d/dd'ddddddd.�
|d0dd(d
d
ddddd
�
|d1dd(d
d
ddddd
�
|d1dd(d
d
ddddd
�
|d2dd(d
dddddd�
|d3dd(d
dddddd�
|d3dd(d
dddddd�
|d4dd(d
ddddd#d�
|d5dd(d
ddddd#d�
|d5dd(d
ddddd#d�
|d6dd(d
ddddd	d�
dS)7Ncs �jtj||�dd�|�dS)Nr$r@)rrru)�valueroZexpected)rrr
�checksz+CalculationTests.test_week_0.<locals>.checkz2015 0 0z%Y %U %wi�r(�rr ijz%Y %W %wi�r$r>z2015 1 1z%G %V %ur�ikz2015 0 1z2015 1 2�ilz2015 0 2z2015 1 3r�r4imz2015 0 3z2015 1 4r'z2015 0 4z2015 1 5z2015 0 5z2015 1 6r�z2015 0 6z2015 1 7z2009 0 0i�i�z2009 1 1z2009 0 1z2009 1 2z2009 0 2z2009 1 3inz2009 0 3z2009 1 4z2009 0 4z2009 1 5z2009 0 5z2009 1 6z2009 0 6z2009 1 7r)rr�r)rr
�test_week_0sVzCalculationTests.test_week_0N�r�r$r$�r�r(r��r�r(r��r�r(r�)r�r�r�r�)r�)rrrrrr�r�r�rZ
is_androidr�r�r�r�rrrr
r��s		/r�c@sBeZdZdZdd�Zdd�Zdd�Zdd	�Zej	d
�dd��Z
d
S)�
CacheTestsz!Test that caching works properly.cCsXtjdd�tjdd�dtjj_tj}tjdd�|j|tj�|jttj�d�dS)N�10z%drrz%Y�Nir$)	rru�
_TimeRE_cacher=r8�assertIsNotr�len�_regex_cache)rZoriginal_time_rerrr
�test_time_re_recreationGs
z"CacheTests.test_time_re_recreationcCspytjd=Wntk
r YnXd}x&ttj�tjkrLdtj|<|d7}q(Wtjdd�|jttj�d�dS)Nz%drr$r�)rr��KeyErrorr�Z_CACHE_MAX_SIZErur)rZ	bogus_keyrrr
�test_regex_cleanupRs
zCacheTests.test_regex_cleanupcCs2tjj}dtjj_tjdd�|j|tjj�dS)Nr�r�z%d)rr�r=r8rur�)rZlocale_time_idrrr
�test_new_localetime_s
zCacheTests.test_new_localetimecCs�tjtj�}ytjtjd�Wn tjk
r>|jd�YnXzhtjdd�tj}y0tjtjd	�tjdd�tj}|j	||�Wn tjk
r�|jd�YnXWdtjtj|�XdS)
N�en_US�UTF8ztest needs en_US.UTF8 localer�z%d�de_DEztest needs de_DE.UTF8 locale)r�r�)r�r�)
rr	r
�	setlocale�Errorr�rrur�r�)rZlocale_info�
first_time_re�second_time_rerrr
�test_TimeRE_recreation_localegs z(CacheTests.test_TimeRE_recreation_localezSTD-1DST,M4.1.0,M10.1.0cCstj}tjtjdd�}|j|jd�tjtjdd�}|j|jd�tj}dtjd<tj	�tjtjdd�}|j|jd�tjtjdd�}|j|jd�tj}|j
||�|jt��tj|dd�WdQRX|jt��tj|dd�WdQRXdS)Nrz%Zr$zEST+05EDT,M3.2.0,M11.1.0ZTZ)
rr�rrurr�r��os�environr�r�rsrt)rZ	oldtznameZtmr�r�rrr
�test_TimeRE_recreation_timezone�s$
z*CacheTests.test_TimeRE_recreation_timezoneN)rrrrr�r�r�r�rZrun_with_tzrrrrr
r�Ds
r��__main__)rZunittestrrrbr�Ztestrr�rr�rZTestCaserrr:rmr�r�r�r�r�mainrrrr
�<module>s(Z[[	\