#NEWLINE# def __getattr__( self , attr ) : #NEWLINE# #INDENT# "Asserts that val has attribute attr and that attribute's value is equal to other via a dynamic assertion of the form: has_<attr>()." #NEWLINE# if ( not attr . startswith ( 'has_' ) ) : #NEWLINE# #INDENT# raise AttributeError ( ( 'assertpy has no assertion <%s()>' % attr ) ) #NEWLINE# #UNINDENT# attr_name = attr [ 4 : ] #NEWLINE# if ( not hasattr ( self . val , attr_name ) ) : #NEWLINE# #INDENT# raise AttributeError ( ( 'val has no attribute <%s>' % attr_name ) ) #NEWLINE# #UNINDENT# def _wrapper( * args , **kwargs ) : #NEWLINE# #INDENT# if ( len ( args ) != 1 ) : #NEWLINE# #INDENT# raise TypeError ( ( 'assertion <%s()> takes exactly 1 argument (%d given)' % ( attr , len ( args ) ) ) ) #NEWLINE# #UNINDENT# other = args [ 0 ] #NEWLINE# val_attr = getattr ( self . val , attr_name ) #NEWLINE# if callable ( val_attr ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# val = val_attr ( ) #NEWLINE# #UNINDENT# except TypeError : #NEWLINE# #INDENT# raise TypeError ( ( 'val does not have zero-arg method <%s()>' % attr_name ) ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# val = val_attr #NEWLINE# #UNINDENT# if ( val != other ) : #NEWLINE# #INDENT# self . _err ( ( 'Expected <%s> to be equal to <%s>, but was not.' % ( val , other ) ) ) #NEWLINE# #UNINDENT# return self #NEWLINE# #UNINDENT# return _wrapper