'Fail if there are no instances of theClass in theList with given params'

def failUnlessContainsInstanceOf(self, theClass, params, theList, msg=None):

    self.failIfNoMessage(theList)
    failure = (msg or ('no    %s    instances    in    %s' % (theClass.__name__, `theList`)))
    for item in theList:
        if issubclass(item.__class__, theClass):
            if (not params):
                return
            for (k, v) in params.items():
                if (str(item.params[k]) != v):
                    failure = ('%s.%s    value    was    %s,    expected    %s' % (theClass.__name__, k, item.params[k], v))
                    break
            else:
                return
    raise self.failureException, failure
