def provides(interface):
 interface_name = interface.__name__
 def invariant(value):
  if interface.providedBy(value):
   return (True, '')
  else:
   return (False, "{value!r} doesn't provide {interface}".format(value=value, interface=interface_name))
 invariant.__name__ = 'provides_{}_invariant'.format(interface_name)
 return invariant

def provides ( interface ) : interface_name = interface . __name__ def invariant ( value ) : if interface . providedBy ( value ) : return ( True , '' ) else : return ( False , "{value!r} doesn't provide {interface}" . format ( value = value , interface = interface_name ) ) invariant . __name__ = 'provides_{}_invariant' . format ( interface_name ) return invariant
create an invariant that asserts that the given value provides the given interface .