#NEWLINE# def test_patch_class( self ) : #NEWLINE# #INDENT# record_calls = [ ] #NEWLINE# class TestClass ( object ) : #NEWLINE# #INDENT# def f1( self ) : #NEWLINE# #INDENT# sleep ( 0.05 ) #NEWLINE# #UNINDENT# def f2( self ) : #NEWLINE# #INDENT# sleep ( 0.1 ) #NEWLINE# self . f1 ( ) #NEWLINE# #UNINDENT# def f3( self ) : #NEWLINE# #INDENT# record_calls . append ( 1 ) #NEWLINE# #UNINDENT# #UNINDENT# unpatched = TestClass ( ) #NEWLINE# unpatched . f1 ( ) #NEWLINE# unpatched . f3 ( ) #NEWLINE# t = MonkeyTimer ( ) #NEWLINE# TestClass = t . patch_class_all ( TestClass , 'cls.' ) #NEWLINE# patched = TestClass ( ) #NEWLINE# patched . f1 ( ) #NEWLINE# patched . f2 ( ) #NEWLINE# patched . f3 ( ) #NEWLINE# self . assertAlmostEqual ( 0.1 , t . _clock_time [ 'cls.f1' ] , delta = 0.01 ) #NEWLINE# self . assertEqual ( 2 , t . _total_count [ 'cls.f1' ] ) #NEWLINE# self . assertEqual ( 2 , len ( record_calls ) ) #NEWLINE# self . assertAlmostEqual ( 0.075 , t . _proportional_time [ 'cls.f1' ] , delta = 0.01 )