#NEWLINE# def testDuration( self ) : #NEWLINE# #INDENT# ' Test computation of event duration before the end of a period ' #NEWLINE# events = ( ( ( 2013 , 1 , 1 , 0 , 0 , 0 ) , ( 2013 , 1 , 31 , 0 , 0 , 0 ) , 31 ) , ( ( 2013 , 3 , 1 , 0 , 0 , 0 ) , ( 2013 , 4 , 2 , 0 , 0 , 0 ) , 33 ) , ( ( 2013 , 3 , 8 , 0 , 0 , 0 ) , ( 2013 , 8 , 5 , 0 , 0 , 0 ) , 116 ) , ( ( 2013 , 5 , 1 , 0 , 0 , 0 ) , ( 2013 , 9 , 21 , 0 , 0 , 0 ) , 62 ) , ( ( 2013 , 5 , 1 , 0 , 0 , 0 ) , ( 2013 , 5 , 5 , 0 , 0 , 0 ) , 5 ) , ( ( 2013 , 8 , 5 , 0 , 0 , 0 ) , ( 2013 , 9 , 16 , 0 , 0 , 0 ) , 0 ) ) #NEWLINE# period = self . period #NEWLINE# for ( index , event ) in enumerate ( events ) : #NEWLINE# #INDENT# ( start , end , expected_duration ) = event #NEWLINE# tp_event = S3TimeSeriesEvent ( index , start = tp_datetime ( * start ) , end = tp_datetime ( * end ) ) #NEWLINE# duration = period . duration ( tp_event , 'days' ) #NEWLINE# self . assertEqual ( duration , expected_duration , msg = ( 'Incorrect result for duration of event %s: %s != %s.' % ( ( events + 1 ) , duration , expected_duration ) ) )