Пример #1
0
    def _testClasses(self):
        if self._tClasses is None:
            self._tClasses = []
            mod = self.original
            if hasattr(mod, '__tests__'):
                warnings.warn(("to allow for compatibility with python2.4's "
                               "doctest module, please use a __unittests__ "
                               "module attribute instead of __tests__"),
                               DeprecationWarning)
                objects = mod.__tests__
            elif hasattr(mod, '__unittests__'):
                objects = mod.__unittests__
            else:
                names = dir(mod)
                objects = [getattr(mod, name) for name in names]

            for obj in objects:
                if isinstance(obj, (components.MetaInterface, zi.Interface)):
                    continue
                try:
                    if ITestCaseFactory.providedBy(obj):
                        self._tClasses.append(obj)
                except AttributeError:
                    # if someone (looking in exarkun's direction)
                    # messes around with __getattr__ in a particularly funky
                    # way, it's possible to mess up zi's providedBy()
                    pass

        return self._tClasses
Пример #2
0
 def addTestClass(self, testClass):
     if ITestCaseFactory.providedBy(testClass):
         self.tests.append(testClass)
     else:
         warnings.warn(("didn't add %s because it does not implement "
                        "ITestCaseFactory" % testClass))