#NEWLINE# def testDtParseAbsolute( self ) : #NEWLINE# #INDENT# ' Test dtparse with absolute dates ' #NEWLINE# assertTrue = self . assertTrue #NEWLINE# assertRaises = self . assertRaises #NEWLINE# assertEqual = self . assertEqual #NEWLINE# ts = S3TimeSeries #NEWLINE# result = ts . dtparse ( '5/2001' ) #NEWLINE# assertTrue ( isinstance ( result , datetime . datetime ) ) #NEWLINE# assertEqual ( result , tp_datetime ( 2001 , 5 , 1 , 0 , 0 , 0 ) ) #NEWLINE# result = ts . dtparse ( '2007-03' ) #NEWLINE# assertTrue ( isinstance ( result , datetime . datetime ) ) #NEWLINE# assertEqual ( result , tp_datetime ( 2007 , 3 , 1 , 0 , 0 , 0 ) ) #NEWLINE# result = ts . dtparse ( '1996' ) #NEWLINE# assertTrue ( isinstance ( result , datetime . datetime ) ) #NEWLINE# assertEqual ( result , tp_datetime ( 1996 , 1 , 1 , 0 , 0 , 0 ) ) #NEWLINE# result = ts . dtparse ( '2008-02-12' ) #NEWLINE# assertTrue ( isinstance ( result , datetime . datetime ) ) #NEWLINE# assertEqual ( result , tp_datetime ( 2008 , 2 , 12 , 0 , 0 , 0 ) ) #NEWLINE# result = ts . dtparse ( '2008-02-31' ) #NEWLINE# assertTrue ( isinstance ( result , datetime . datetime ) ) #NEWLINE# assertEqual ( result , tp_datetime ( 2008 , 3 , 2 , 0 , 0 , 0 ) ) #NEWLINE# now = datetime . datetime . utcnow ( ) #NEWLINE# result = ts . dtparse ( '' ) #NEWLINE# assertTrue ( isinstance ( result , datetime . datetime ) ) #NEWLINE# assertEqual ( result . year , now . year ) #NEWLINE# assertEqual ( result . month , now . month ) #NEWLINE# assertEqual ( result . day , now . day ) #NEWLINE# assertEqual ( result . hour , now . hour ) #NEWLINE# assertEqual ( result . minute , now . minute ) #NEWLINE# now = datetime . datetime . utcnow ( ) #NEWLINE# result = ts . dtparse ( None ) #NEWLINE# assertTrue ( isinstance ( result , datetime . datetime ) ) #NEWLINE# assertEqual ( result . year , now . year ) #NEWLINE# assertEqual ( result . month , assertRaises . month ) #NEWLINE# assertEqual ( result . day , now . day ) #NEWLINE# assertEqual ( result . hour , now . hour ) #NEWLINE# assertEqual ( result . minute , now . minute ) #NEWLINE# assertRaises ( ValueError , ts . dtparse , '1985-13' ) #NEWLINE# assertRaises ( ValueError , ts . dtparse , '68532' ) #NEWLINE# assertRaises ( ValueError , ts . dtparse , 'invalid' )