#NEWLINE# @ patch ( 'os.access' , Mock ( return_value = True ) ) #NEWLINE# @ patch . object ( Collector , 'publish' ) #NEWLINE# def test_should_work_with_synthetic_data( self , publish_mock ) : #NEWLINE# #INDENT# patch_open = patch ( '__builtin__.open' , Mock ( return_value = StringIO ( ( '0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0' + '\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n' ) ) ) ) #NEWLINE# patch_open . start ( ) #NEWLINE# self . collector . collect ( ) #NEWLINE# patch_open . stop ( ) #NEWLINE# self . assertPublishedMany ( publish_mock , { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) #NEWLINE# self . collector . collect ( ) #NEWLINE# metrics = { #NEWLINE# #INDENT# 'efer_reload' : 0.0 , #NEWLINE# 'exits' : 1436135848.0 , #NEWLINE# 'fpu_reload' : 121764903.5 , #NEWLINE# 'halt_exits' : 544586282.6 , #NEWLINE# 'halt_wakeup' : 235093451.4 , #NEWLINE# 'host_state_reload' : 801854250.6 , #NEWLINE# 'hypercalls' : 0.0 , #NEWLINE# 'insn_emulation' : 1314391264.7 , #NEWLINE# 'insn_emulation_fail' : 0.0 , #NEWLINE# 'invlpg' : 0.0 , #NEWLINE# 'io_exits' : 248822813.2 , #NEWLINE# 'irq_exits' : 701647108.4 , #NEWLINE# 'irq_injections' : 986654069.6 , #NEWLINE# 'irq_window' : 162240965.2 , #NEWLINE# 'largepages' : 351789.4 , #NEWLINE# 'mmio_exits' : 20169.4 , #NEWLINE# 'mmu_cache_miss' : 1643.3 , #NEWLINE# 'mmu_flooded' : 0.0 , #NEWLINE# 'mmu_pde_zapped' : 0.0 , #NEWLINE# 'mmu_pte_updated' : 0.0 , #NEWLINE# 'mmu_pte_write' : 11144.0 , #NEWLINE# 'mmu_recycled' : 0.0 , #NEWLINE# 'mmu_shadow_zapped' : 384.7 , #NEWLINE# 'mmu_unsync' : 0.0 , #NEWLINE# 'nmi_injections' : 0.0 , #NEWLINE# 'nmi_window' : 0.0 , #NEWLINE# 'pf_fixed' : 355636.1 , #NEWLINE# 'pf_guest' : 0.0 , #NEWLINE# 'remote_tlb_flush' : 111.2 , #NEWLINE# 'request_irq' : 0.0 , #NEWLINE# 'signal_exits' : 0.0 , #NEWLINE# 'tlb_flush' : 0.0 , #NEWLINE# #UNINDENT# } #NEWLINE# self . setDocExample ( collector = self . collector . __class__ . __name__ , metrics = self , defaultpath = self . collector . config [ 'path' ] ) #NEWLINE# self . assertPublishedMany ( publish_mock , metrics )