示例#1
0
    def verify(self, failIfImportErrors=True, checkReporterSetup=True):
        if checkReporterSetup:
            for v in 'setUpReporterCalled', 'tearDownReporterCalled':
                assert_(getattr(self, v), 'self.%s did not evaluate to non-zero' % (v,))

        if failIfImportErrors:
            assert_(not self.importError)

        for n in self.names:
            assertEqual(self.startCtr[n], self.endCtr[n])
示例#2
0
def stringComparison(expect, output):
    """compares the list of strings in output to the list of objects in 
    expect. expect and output are not altered

    @param output: a list of strings, '' is ignored 
    @type output: list

    @param expect: a list of strings, None, or _sre.SRE_Pattern objects 
    (the object returned by re.compile()).
    
      - with string objects a simple == comparison is done
      - with regex objects, a match() is done and if there is no Match object
        returned, FailTest is raised
      - a None object causes a non blank string in output to be ignored

    @type expect: types.ListType
    """
    _expect, _output = expect[:], output[:]
    while 1:
        if not _output:
            return
        out = _output.pop(0)
        if out == '':
            continue
        else:
            if not _expect:
                return
            exp = _expect.pop(0)
            if exp is None:
                continue
            elif isinstance(exp, types.StringType):
                assertSubstring(exp, out)
            elif isinstance(exp, REGEX_PATTERN_TYPE):
                assert_(exp.match(out), "%r did not match string %r" % (exp.pattern, out))
            else:
                raise TypeError, "don't know what to do with object %r" % (exp,)