a ze,@sdZddlZddlZddlZddlmZddlZddlZddZddZ Gdd d ej Z Gd d d ej Z e d kr|edS) z Unittest for time.strftime N)supportcCs,|ddkr(|ddd|dd}|S)N 0 )srrF/opt/bitninja-python-dojo/embedded/lib/python3.9/test/test_strftime.py fixasctimes r cCsDt|}|t||}|dd}|dd}|dd}|S)z Escape text to deal with possible locale values that have regex syntax while allowing regex syntax used for comparison. z\%%z\::z\??)reescapereplace)textampmZnew_textrrr escapestrs     rc@s4eZdZddZddZddZddZd d Zd S) StrftimeTestc Cst||_t|}|ddkr*d|_nd|_tt|dddddddddf |_z&|drptjd|_n tjd|_Wnt yd|_Yn0|ddkr|dd|_ n|ddkr|d|_ nd|_ ||_ dS) N z(AM|am)z(PM|pm)rr) timegmtimeZgmt localtimermktimejan1tznametzAttributeErrorclock12now)selfr"rrr _update_variables"s  (  zStrftimeTest._update_variablescCshz ddl}|jj|jjjWnBtybddlm}m}||}||d| |||Yn0dS)Nr) setlocaleLC_TIMEC) javautilZLocaleZ setDefaultZUS ImportErrorlocaler%r&Z addCleanup)r#r(r%r&Z saved_localerrr setUp8s  zStrftimeTest.setUpcCst}||||||tjrHtdtjtj dft ddD]H}t dD]:}|||ddd}||||||q^qRdS) Nz/Strftime test, platform: %s, Python version: %srdi) rr$ strftest1 strftest2rverboseprintsysplatformversionsplitrange)r#r"jiargrrr test_strftimeBs      zStrftimeTest.test_strftimecCsRtjrtdt||j}dtj|ddfdtj|ddfdtj |dd fd tj |dd fd d |ddfdd |ddfdd |j dfdd|ddfdd |ddfdd |ddfd|j dfd d |d!d"fd#d |d|j ddd$fd%d&d|ddd'fd(d |d|j ddddd)fd*d+|d|d|d!fd,fd-d |d.d/d0fd1d |d.d2fd3f}|D]}zt|d.|}Wn<ty}z"|d4|d.|fWYd}~n d}~00tt|d|j |rq|r |d.d5kr(|d6|d.|dfn"|d7|d.|d|d|fqdS)8Nzstrftime test forz%azabbreviated weekday namez%Azfull weekday namez%brabbreviated month namez%Bzfull month namez%dz%02dzday of month as number (00-31)z%Hrz hour (00-23)z%Iz hour (01-12)z%j%03dzjulian day (001-366)z%mzmonth as number (01-12)z%Mzminute, (00-59)z%pzAM or PM as appropriatez%Sr.zseconds of current time (00-60)z%Uz!week number of the year (Sun 1st)z%wz0?%dzweekday as a number (Sun 1st)z%Wz!week number of the year (Mon 1st)z%X%02d:%02d:%02d%H:%M:%S%yrr0zyear without centuryz%Yzyear with century)z%%r zsingle percent signz#strftime '%s' format gave error: %sr z3strftime does not support standard '%s' format (%s)z-Conflict for %s (%s): expected %s, but got %s)rr4r5rctimer"calendarZday_abbrZday_name month_abbrZ month_namer!rrstrftime ValueErrorZfailrmatchr)r#r"Z expectationseresulterrorrrr r2SsR ",zStrftimeTest.strftest1cCsVtt|dd}|j}dtt|dfdd|d|d|dd fd fd d |jd fdd|d|d|dd fdfdd|ddfdtj|ddfdd|ddfddd|j |d|d|j fdfdd|d|dfd fd |d!fd"d#d$|d|d|dfd%fd&d'|dd d(ff}|D] }zt |d|}Wn^t y}zDd)|d|dt|f}t jrt|WYd}~q.WYd}~n d}~00tt|d|j |rt jrNtd*|d|dfnj|r|dd+krt jrNtd,|d|dfn4t jr.td-|d|dftd.|d|fq.dS)/Nz%cznear-asctime() formatz%xz%02d/%02d/%02drrArr0z%m/%d/%y %H:%M:%Sz%Zz%sztime zone namez%Dzmm/dd/yyz%ez%2dz,day of month as number, blank padded ( 0-31)z%hr@z%krzhour, blank padded ( 0-23))z%n znewline characterz%rz%02d:%02d:%02d %srDr.z %I:%M:%S %pz%Rz %02d:%02dz%H:%Mzseconds since the Epoch in UCT)z%t z tab characterz%TrErFz%3yrBz.year without century rendered using fieldwidthz*Error for nonstandard '%s' format (%s): %sz%Supports nonstandard '%s' format (%s)r z+Does not appear to support '%s' format (%s)z*Conflict for nonstandard '%s' format (%s):z Expected %s, but got %s)strintr"r rasctimerrIrJr!rrKrLrr4r5rrMr)r#r"ZnowsecsZnonstandard_expectationsrNrOmsgrrr r3s\" $zStrftimeTest.strftest2N)__name__ __module__ __qualname__r$r,r>r2r3rrrr r s  0rc@s(eZdZdZddZddZddZdS) Y1900TestszA limitation of the MS C runtime library is that it crashes if a date before 1900 is passed with a format string containing "%y" cCsjd}tjdkstjdrR|ttd|Wdqf1sF0Yn|td|ddS)N) ikrrrrrrrrwin32)ZaixZsunosZsolarisrGZ99)r6r7 startswithZ assertRaisesrLrrK assertEqual)r#trrr test_y_before_1900s   ,zY1900Tests.test_y_before_1900cCs|tddddS)NrG) ilrrrrrrrrZ00r^rrKr#rrr test_y_1900s zY1900Tests.test_y_1900cCs|tddddS)NrG) irrrrrrrrZ13rarbrrr test_y_after_1900s zY1900Tests.test_y_after_1900N)rXrYrZ__doc__r`rcrdrrrr r[s r[__main__)rerIr6rtestrrZunittestr rZTestCaserr[rXmainrrrr s