'return a testreport whose dotted import path matches'

def matchreport(self, inamepart='', names='pytest_runtest_logreport    pytest_collectreport', when=None):

    l = []
    for rep in self.getreports(names=names):
        try:
            if ((not when) and (rep.when != 'call') and rep.passed):
                continue
        except AttributeError:
            pass
        if (when and (getattr(rep, 'when', None) != when)):
            continue
        if ((not inamepart) or (inamepart in rep.nodeid.split('::'))):
            l.append(rep)
    if (not l):
        raise ValueError(('could    not    find    test    report    matching    %r:    no    test    reports    at    all!' % (inamepart,)))
    if (len(l) > 1):
        raise ValueError(('found    2    or    more    testreports    matching    %r:    %s' % (inamepart, l)))
    return l[0]
