%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/local/lib/python2.7/test/
Upload File :
Create Path :
Current File : //usr/local/lib/python2.7/test/test_strptime.pyo


Nac@sedZddlZddlZddlZddlZddlZddlZddlmZ	ddl
mZddl
Z
dejfdYZdejfdYZd	ejfd
YZdejfdYZd
ejfdYZdejfdYZdejfdYZdejfdYZdZedkraendS(sPyUnit testing against strptimeiN(ttest_support(tdatet
getlang_TestscBseZdZdZRS(s
Test _getlangcCs&|jtjtjtjdS(N(tassertEqualt	_strptimet_getlangtlocalet	getlocaletLC_TIME(tself((s./usr/local/lib/python2.7/test/test_strptime.pyt
test_basics(t__name__t
__module__t__doc__R
(((s./usr/local/lib/python2.7/test/test_strptime.pyRstLocaleTime_TestscBsVeZdZdZdZdZdZdZdZdZ	dZ
RS(	sTests for _strptime.LocaleTime.

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

    cCs"tj|_tj|_dS(s(Create time tuple based on current time.N(ttimet	localtimet
time_tupleRt
LocaleTimetLT_ins(R	((s./usr/local/lib/python2.7/test/test_strptime.pytsetUpscCsgtj||jj}||j|}|j||d||j||d|||fdS(sHelper method that tests testing against directive based on the
        tuple_position of time_tuple.  Uses error_msg as error message.

        s%s: not found in tuples-%s: position within tuple incorrect; %s != %sN(RtstrftimeRtlowertassertInR(R	ttestingt	directivettuple_positiont	error_msgtstrftime_outputt
comparison((s./usr/local/lib/python2.7/test/test_strptime.pytcompare_against_time scCs<|j|jjddd|j|jjddddS(Ns%Ais#Testing of full weekday name faileds%as*Testing of abbreviated weekday name failed(RRt	f_weekdayt	a_weekday(R	((s./usr/local/lib/python2.7/test/test_strptime.pyttest_weekday.scCs<|j|jjddd|j|jjddddS(Ns%Bis&Testing against full month name faileds%bs-Testing against abbreviated month name failed(RRtf_monthta_month(R	((s./usr/local/lib/python2.7/test/test_strptime.pyt
test_month6scCswtjd|jj}|j||jjd|jddkrPd}nd}|j|jj||ddS(Ns%ps!AM/PM representation not in tupleiiiis;AM/PM representation in the wrong position within the tuple(RRRRRRtam_pmR(R	Rtposition((s./usr/local/lib/python2.7/test/test_strptime.pyt
test_am_pm>s	cCsntjd|jj}|rj|j||jjdkpP||jjdkd||jjfndS(Ns%Ziistimezone %s not found in %s(RRRRt
assertTrueRttimezone(R	R)((s./usr/local/lib/python2.7/test/test_strptime.pyt
test_timezoneHsc	Csd}tjd
|}|jtj|jj||dtjd|}|jtj|jj||d
tjd|}|jtj|jj||dtj}d|_	|j
|jddS(Niiiii,i7iiLis%csLC_date_time incorrects%xsLC_date incorrects%XsLC_time incorrectts6LocaleTime's LC directives cannot handle empty strings(	iiiii,i7iiLi(R+R+(RRRRtLC_date_timetLC_datetLC_timeRRR%R((R	t
magic_dateRtLT((s./usr/local/lib/python2.7/test/test_strptime.pyttest_date_timeQs


	cCs |j|jjtjdS(N(RRtlangRR(R	((s./usr/local/lib/python2.7/test/test_strptime.pyt	test_langgs(RRR
RRR!R$R'R*R1R3(((s./usr/local/lib/python2.7/test/test_strptime.pyRs					
			tTimeRETestscBsVeZdZdZdZdZdZdZdZdZ	dZ
RS(	sTests for TimeRE.cCs"tj|_tj|_dS(s Construct generic TimeRE object.N(RtTimeREttime_reRtlocale_time(R	((s./usr/local/lib/python2.7/test/test_strptime.pyRpscCs|jjd}|j|j|jjddkd||j|j|jjddkd||j|j|jddkd|dS(	Ns%a %A %diis7did not find abbreviated weekday in pattern string '%s'is0did not find full weekday in pattern string '%s'tds.did not find 'd' directive pattern string '%s'(R6tpatternR(tfindR7R R(R	tpattern_string((s./usr/local/lib/python2.7/test/test_strptime.pyttest_patternus""cCs-|jjd}|jd|d|dS(Ns\d+s\\d\+s/%s does not have re characters escaped properly(R6R9R(R	R;((s./usr/local/lib/python2.7/test/test_strptime.pyttest_pattern_escapingscCs|jjdj|jjd}|j|oM|jd|jjdkd|jjd}|jd|jjd|jjdf}|j|d|j	d|jjd|jjdff|j|jd	|jjdko|jd
|jjdkd|j
|jj	|jd	|jd
fxjd D]b}|jjd|}|jtj
d|}|j|dtj
d||j	fqHWdS(!Ns%AitAsre object for '%A' faileds%a %bs%s %sis,Match failed with '%s' regex and '%s' stringtatbskre object couldn't find the abbreviated weekday month in '%s' using '%s'; group 'a' = '%s', group 'b' = %s'tBtcR8tHtItjtmtMtptStUtwtWtxtXtytYtZt%s(Matching failed on '%s' using '%s' regex(R?R>R@RARBR8RCRDRERFRGRHRIRJRKRLRMRNRORPRQRR(R6tcompiletmatchR7RR(tgroupR R#R9tstringtreRR(R	tfoundtcompiledR((s./usr/local/lib/python2.7/test/test_strptime.pyttest_compiles,%(	%
cCsJtj}ttf|_|jtj|jddddS(Ns%ZR+s6with timezone == ('',''), TimeRE().pattern('%Z') != ''(RRt	frozensetR)RR5R9(R	ttest_locale((s./usr/local/lib/python2.7/test/test_strptime.pyttest_blankpatternscCs5|jjd}|jd}|j|ddS(Ns\w+ %ms\w+ 10s"Escaping failed of format '\w+ 10'(R6RSRTR((R	tcompiled_reRX((s./usr/local/lib/python2.7/test/test_strptime.pyttest_matching_with_escapesscCs\tj}tdtdf|_tj|}|j|jdjdddS(NtutctgmtsTokyo (standard time)sTokyo (daylight time)s%ZsFlocale data that contains regex metacharacters is not properly escaped(R`RasTokyo (standard time)(RRR[R)R5R(RSRT(R	R7R6((s./usr/local/lib/python2.7/test/test_strptime.pyt'test_locale_data_w_regex_metacharactersscCsH|jjd}|jtj|d|jtj|ddS(Ns%j %Ht180s18 0(R6R9tassertFalseRWRTR((R	R9((s./usr/local/lib/python2.7/test/test_strptime.pyttest_whitespace_substitutions(RRR
RR<R=RZR]R_RbRe(((s./usr/local/lib/python2.7/test/test_strptime.pyR4ms		
					
t
StrptimeTestscBseZdZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdZ
dZd
ZdZdZdZdZdZdZdZdZdZdZdZRS(sTests for _strptime.strptime.cCstj|_dS(sCreate testing time tuple.N(RtgmtimeR(R	((s./usr/local/lib/python2.7/test/test_strptime.pyRscCs|jttjddddxydD]q}ytjd|WnCtk
rVq&q&tk
r}|jd	||jjfq&X|jd
|q&WdS(Ntdata_strings%dtformats%ARRs% s%et2005s'%s' raised %s, not ValueErrors'%s' did not raise ValueError(RRs% s%e(tassertRaisest
ValueErrorRt_strptime_timet	Exceptiontfailt	__class__R(R	t
bad_formatterr((s./usr/local/lib/python2.7/test/test_strptime.pyttest_ValueErrors

	cCs|jttjdddS(Ns10 12s%m(RkRlRRm(R	((s./usr/local/lib/python2.7/test/test_strptime.pyttest_unconverteddatascCsotjd||j}tj|d|}|j|||j|kd|||||j|fdS(sHelper fxn in testing.RRs2testing of '%s' directive failed; '%s' -> %s != %sN(RRRRRmR((R	RR&tstrf_outputtstrp_output((s./usr/local/lib/python2.7/test/test_strptime.pythelpers
cCsxdD]}|j|dqWxdd
fddffD]g\}}xX|D]P}tj|d
}|t|}|j|d|kd||dfqMWq:WdS(NRORPiilt69t99it00t68s%ys1'y' test failed; passed in '%s' and returned '%s'(RORP(RxRy(RzR{(RwRRmtintR((R	RtcenturytboundstboundRvtexpected_result((s./usr/local/lib/python2.7/test/test_strptime.pyt	test_years
%
cCs%xdD]}|j|dqWdS(NRAR@RFi(RAR@RF(Rw(R	R((s./usr/local/lib/python2.7/test/test_strptime.pyR$s
cCs|jdddS(NR8i(Rw(R	((s./usr/local/lib/python2.7/test/test_strptime.pyttest_dayscCst|jddtjd|j}tj|d}|j|d|jdkd||d|jdfdS(NRCis%I %ps7testing of '%%I %%p' directive failed; '%s' -> %s != %s(RwRRRRRmR((R	RuRv((s./usr/local/lib/python2.7/test/test_strptime.pyt	test_hourscCs|jdddS(NRGi(Rw(R	((s./usr/local/lib/python2.7/test/test_strptime.pyttest_minute
scCs|jdddS(NRIi(Rw(R	((s./usr/local/lib/python2.7/test/test_strptime.pyttest_secondscCseddl}|jddddddd}tjt|dd	\}}|j||jdS(
Niiiii"i8i4Ris%Y-%m-%d %H:%M:%S.%f(tdatetimeRtstrRtmicrosecond(R	RR8ttuptfrac((s./usr/local/lib/python2.7/test/test_strptime.pyt
test_fractions!!cCs%xdD]}|j|dqWdS(NR>R?RKi(R>R?RK(Rw(R	R((s./usr/local/lib/python2.7/test/test_strptime.pyR!s
cCs|jdddS(NREi(Rw(R	((s./usr/local/lib/python2.7/test/test_strptime.pyttest_julianscCstjdd}|j|jdtjdd}|j|jdtj}tjd}tj|d}tj}tjdtjdkstj	r|j
|d|dkd||d|dfn|j
|ddkd	dS(
NtUTCs%ZitGMTiis'timezone check failed; '%s' -> %s != %sis]LocaleTime().timezone has duplicate values and time.daylight but timezone value not set to -1(RRmRttm_isdstRRRRttznametdaylightR((R	RvRRuR7((s./usr/local/lib/python2.7/test/test_strptime.pyR*"s$cCstjd}|jdkr/|jdntjtd||ftjtdd{tjtdd	\||ft_dt_tj|d
d}|j	|dd
tj|tj|fWdQXWdQXWdQXdS(NiRRsneed non-UTC/GMT timezoneRRittzsetcSsdS(N(tNone(((s./usr/local/lib/python2.7/test/test_strptime.pyt<lambda>AR+s%Ziis^%s lead to a timezone value of %s instead of -1 when time.daylight set to %s and passing in %s(RR(
RRtuppertskipTesttsupportt	swap_attrRRRmR(R	ttz_namettz_value((s./usr/local/lib/python2.7/test/test_strptime.pyttest_bad_timezone8s
	cCs+x$tdD]}|jd|q
WdS(NiRB(trangeRw(R	R&((s./usr/local/lib/python2.7/test/test_strptime.pyR1JscCs.x'tddD]}|jd|qWdS(NiiRM(RRw(R	R&((s./usr/local/lib/python2.7/test/test_strptime.pyt	test_dateOscCs.x'tddD]}|jd|qWdS(NiiRN(RRw(R	R&((s./usr/local/lib/python2.7/test/test_strptime.pyt	test_timeTscCsctjd|j}tj|d}|j|d|jdkoX|d|jdkddS(Ns%m %% %Yiishandling of percent sign failed(RRRRRmR((R	RuRv((s./usr/local/lib/python2.7/test/test_strptime.pyttest_percentYs
cCstjd|j}|jtj|jdd|jtj|jdd|jtj|jdddS(Ns%Bs0strptime does not handle ALL-CAPS names properlys1strptime does not handle lowercase names properlys/strptime does not handle capword names properly(	RRRR(RRmRRt
capitalize(R	Ru((s./usr/local/lib/python2.7/test/test_strptime.pyttest_caseinsensitiveasc	Cs<d}tjdd}|j||kd||fdS(	Niliiit1s%ms5Default values for strptime() are incorrect; %s != %s(	iliiiiiiii(RRmR((R	tdefaultsRv((s./usr/local/lib/python2.7/test/test_strptime.pyt
test_defaultsks
cCs#d}|jtj||dS(Ns.^$*+?{}\[]|)((R(RRm(R	t
need_escaping((s./usr/local/lib/python2.7/test/test_strptime.pyt
test_escapingsscCstjdddS(NsFeb 29s%b %d(Rtstrptime(R	((s./usr/local/lib/python2.7/test/test_strptime.pyt$test_feb29_on_leap_year_without_year|scCs,|jtjddtjdddS(NsFeb 29s%b %dsMar 1(t
assertLessRR(R	((s./usr/local/lib/python2.7/test/test_strptime.pyt7test_mar1_comes_after_feb29_even_when_omitting_the_years(RRR
RRsRtRwRR$RRRRRR!RR*RR1RRRRRRRR(((s./usr/local/lib/python2.7/test/test_strptime.pyRfs2						
																
				tStrptime12AMPMTestscBseZdZdZRS(s9Test a _strptime regression in '%I %p' at 12 noon (12 PM)cCs|j}|tjdddd|tjdddd|tjdddd|tjdddddS(Ns12 PMs%I %piis12 AMi(RRRRRm(R	teq((s./usr/local/lib/python2.7/test/test_strptime.pyttest_twelve_noon_midnights
	(RRR
R(((s./usr/local/lib/python2.7/test/test_strptime.pyRstJulianTestscBseZdZdZRS(s@Test a _strptime regression that all julian (1-366) are acceptedcCsH|j}x8tddD]'}|tjd|dd|qWdS(Niios%d 2004s%j %Yi(RRRRm(R	Rti((s./usr/local/lib/python2.7/test/test_strptime.pyttest_all_julian_dayss	(RRR
R(((s./usr/local/lib/python2.7/test/test_strptime.pyRstCalculationTestscBsDeZdZdZdZdZdZdZdZRS(s4Test that strptime() fills in missing info correctlycCstj|_dS(N(RRgR(R	((s./usr/local/lib/python2.7/test/test_strptime.pyRscCs]d}tjtj||j|}|j|j|jjkd|j|jjfdS(Ns%Y %m %d %H %M %S %w %Zs'Calculation of tm_yday failed; %s != %s(RRmRRRR(ttm_yday(R	t
format_stringtresult((s./usr/local/lib/python2.7/test/test_strptime.pyttest_julian_calculations	c	Csd}tjtj||j|}|j|j|jjkoi|j|jjkoi|j|jjkd|j|j|j|jj|jj|jjfdS(Ns%Y %H %M %S %w %j %Zs:Calculation of Gregorian date failed; %s-%s-%s != %s-%s-%s(	RRmRRRR(ttm_yearttm_monttm_mday(R	RR((s./usr/local/lib/python2.7/test/test_strptime.pyttest_gregorian_calculations	cCs]d}tjtj||j|}|j|j|jjkd|j|jjfdS(Ns%Y %m %d %H %S %j %Zs/Calculation of day of the week failed; %s != %s(RRmRRRR(ttm_wday(R	RR((s./usr/local/lib/python2.7/test/test_strptime.pyttest_day_of_week_calculations	csfd}|d-d|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,dS(ANcsxdD]}d|}t|}|j|}tj||}j|d |kd||||d ||d|jdfqWdS(NRLRJs%%Y %%%s %%wis/%s(%s) test failed w/ '%s': %s != %s (%s != %s)i(RLRJ(t
datetime_dateRRRmR(t	timetuple(t	ymd_tuplettest_reasonRRtdt_datet
strp_inputRv(R	(s./usr/local/lib/python2.7/test/test_strptime.pyttest_helpers

	
imiisweek 0iscommon casei
s
day on Sundayis
day on MondayiqsJan 1 on SundayirsJan 1 on Mondayis)first Sunday in a year starting on MondayiisDec 31 on SundaysDec 31 on Mondayiis#Monday in the last week of the yearis-Monday in the second-to-last week of the yearii
israndomly chosen dateiisEyear starting and ending on Monday while date not on Sunday or Mondayi}isXyear starting and ending on Monday with a Monday not at the beginning or end of the years8Dec 31 on Monday with year starting and ending on MondayisFirst Sunday of 2007sSecond Sunday of 2007isLast Sunday of 2006isSecond to last Sunday of 2006(imii(imii(imii
(imii(iqii(irii(irii(iqii(irii(iii(iii(ii
i(iii(ii
i(i}ii(i}ii(iii(iii(iii(iii((R	R((R	s./usr/local/lib/python2.7/test/test_strptime.pyt-test_week_of_year_and_day_of_week_calculations*


















csfd}|dddddddddd	
|dd
ddd
ddddd

|dddddddddd
|dd
dddddddd
|dddddddddd
|dd
dddddddd
|dddddddddd
|dd
dddddddd
|dddddddddd
|dd
dddddddd
|ddddddddd
d
|dd
ddddddd
d
|dddddddddd
|dd
dddddddd
|dddddddddd
|dd
ddd
ddddd

|d ddddddddd
|d d
dddddddd
|d!ddddddddd
|d!d
dddddddd
|d"ddddddddd#
|d"d
dddddddd#
|d$ddddddddd
|d$d
dddddddd
|d%dddddddd
d
|d%d
ddddddd
d
|d&ddddddddd
|d&d
dddddddd
dS('Ncs$jtj||d |dS(Ni(RRRm(tvalueRitexpected(R	(s./usr/local/lib/python2.7/test/test_strptime.pytcheckss2015 0 0s%Y %U %wiiiiiijs%Y %W %wiiis2015 0 1iiks2015 0 2iils2015 0 3iiims2015 0 4is2015 0 5s2015 0 6is2009 0 0iis2009 0 1s2009 0 2s2009 0 3ins2009 0 4s2009 0 5s2009 0 6((R	R((R	s./usr/local/lib/python2.7/test/test_strptime.pyttest_week_0s:%%%%%%%%%%%%%%%%%%%%%%%%%%%(	RRR
RRRRRR(((s./usr/local/lib/python2.7/test/test_strptime.pyRs							(t
CacheTestscBsJeZdZdZdZdZdZejddZ	RS(s!Test that caching works properly.cCsxtjddtjdddtjj_tj}tjdd|j|tj|jttjddS(Nt10s%dRjs%YtNii(	RRmt
_TimeRE_cacheR7R2tassertIsNotRtlent_regex_cache(R	toriginal_time_re((s./usr/local/lib/python2.7/test/test_strptime.pyttest_time_re_recreation
s	cCsytjd=Wntk
r!nXd}x3ttjtjkr]dtj|<|d7}q+Wtjdd|jttjddS(Ns%diiR(RRtKeyErrorRt_CACHE_MAX_SIZERRmR(R	t	bogus_key((s./usr/local/lib/python2.7/test/test_strptime.pyttest_regex_cleanups

cCsEtjj}dtjj_tjdd|j|tjjdS(NRRs%d(RRR7R2RmR(R	tlocale_time_id((s./usr/local/lib/python2.7/test/test_strptime.pyttest_new_localetime"scCstjtj}ytjtjdWn!tjk
rL|jdnXztjddtj}y@tjtjd	tjddtj}|j	||Wn!tjk
r|jdnXWdtjtj|XdS(
Nten_UStUTF8stest needs en_US.UTF8 localeRs%dtde_DEstest needs de_DE.UTF8 locale(RR(RR(
RRRt	setlocaletErrorRRRmRR(R	tlocale_infot
first_time_retsecond_time_re((s./usr/local/lib/python2.7/test/test_strptime.pyttest_TimeRE_recreation_locale*s 		sSTD-1DST,M4.1.0,M10.1.0cCsJtj}tjtjdd}|j|jdtjtjdd}|j|jdtj}dtjd<tj	tjtjdd}|j|jdtjtjdd}|j|jdtj}|j
|||jttj|ddWdQX|jttj|ddWdQXdS(Nis%ZisEST+05EDT,M3.2.0,M11.1.0tTZ(
RRRRmRRRtostenvironRRRkRl(R	t	oldtznamettmRR((s./usr/local/lib/python2.7/test/test_strptime.pyttest_TimeRE_recreation_timezoneGs$		

	(
RRR
RRRRRtrun_with_tzR(((s./usr/local/lib/python2.7/test/test_strptime.pyRs		
		c	Cs&tjtttttttt	dS(N(
Rtrun_unittestRRR4RfRRRR(((s./usr/local/lib/python2.7/test/test_strptime.pyt	test_maincst__main__(R
tunittestRRRWRtsysttestRRRRRRtTestCaseRRR4RfRRRRRR(((s./usr/local/lib/python2.7/test/test_strptime.pyt<module>s(Z[	o\	


Zerion Mini Shell 1.0