示例#1
0
        def wrapper(): #{{{
            test = TestSuite()
            insys = isfindable(suite)
            selfmod = pathmod(suite) if insys else fromfile(suite)
            test.addTests(sfunc() for sfunc in alltestobjects(selfmod, filenames=(not insys)))
            ret = func()
            if isinstance(ret, TestCase) and ret not in test:
                test.addTest(ret)
                ret = None
            elif isinstance(ret, type) and issubclass(ret, TestCase):
                ret = makeSuite(ret)

            if isinstance(ret, TestSuite) and True not in (t in test for t in ret):
                test.addTest(ret)
            elif ret:
                raise TypeError("Cannot add %s object to test suite" %ret.__class__.__name__)
            return test
示例#2
0
 def suite(): #{{{
     mf = op.abspath(magicfile)
     curmod = pathmod(mf) if isfindable(mf) else fromfile(mf)
     test = TestSuite()
     count = 0
     for attr in dir(curmod):
         a = getattr(curmod, attr)
         if isobjclass(a) and issubclass(a, TestCase):
             if ignore:
                 if (isiterable(ignore) and a in ignore) or a is ignore:
                     continue
             test.addTest(makeSuite(a))
             count += 1
         elif isinstance(a, TestSuite):
             if ignore:
                 if (isiterable(ignore) and a in ignore) or a is ignore:
                     continue
             test.addTest(a)
             count += 1
     if count:
         return test