#NEWLINE# @ qc ( 10 ) #NEWLINE# def get_host_cpu_time( x = list_ ( of = int_ ( min = 1 , max = 1000 ) , min_length = 7 , max_length = 7 ) ) : #NEWLINE# #INDENT# with MockTransaction : #NEWLINE# #INDENT# context = mock ( 'context' ) #NEWLINE# f = mock ( 'file' ) #NEWLINE# expect ( context ) . __enter__ ( ) . and_return ( f ) . once ( ) #NEWLINE# when ( context ) . __exit__ . and_return ( True ) #NEWLINE# expect ( collector ) . open ( '/proc/stat' , 'r' ) . and_return ( context ) . once ( ) #NEWLINE# expect ( f ) . readline ( ) . and_return ( ( ( '1 ' + ' ' . join ( [ str ( v ) for v in x ] ) ) + ' 2 3' ) ) . once ( ) #NEWLINE# assert ( collector . get_host_cpu_time ( ) == ( float ( sum ( x ) ) , float ( sum ( x [ 0 : 3 ] ) ) ) )