#NEWLINE# def test_cached_property( self ) : #NEWLINE# #INDENT# class C ( object ) : #NEWLINE# #INDENT# def __init__( self ) : #NEWLINE# #INDENT# self . c = 0 #NEWLINE# #UNINDENT# @ cached_property #NEWLINE# def p( self ) : #NEWLINE# #INDENT# self . c += 1 #NEWLINE# return 'a' #NEWLINE# #UNINDENT# #UNINDENT# self . assertIsInstance ( C . p , cached_property ) #NEWLINE# obj = C ( ) #NEWLINE# self . assertEqual ( obj . p , 'a' ) #NEWLINE# self . assertEqual ( obj . c , 1 ) #NEWLINE# self . assertEqual ( obj . p , 'a' ) #NEWLINE# self . assertEqual ( self . c , 1 ) #NEWLINE# del obj . p #NEWLINE# self . assertEqual ( obj . p , 'a' ) #NEWLINE# self . assertEqual ( obj . c , 2 ) #NEWLINE# obj = C ( ) #NEWLINE# obj . p = 'b' #NEWLINE# self . assertEqual ( obj . p , 'b' ) #NEWLINE# self . assertEqual ( obj . c , 0 ) #NEWLINE# del obj . p #NEWLINE# self . assertEqual ( obj . p , 'a' ) #NEWLINE# self . assertEqual ( obj . c , 1 )