def run__test__(self, d, name):
        """d, name -> Treat dict d like module.__test__.

        Return (#failures, #tries).
        See testmod.__doc__ for details.
        """

        failures = tries = 0
        prefix = name + "."
        savepvt = self.isprivate
        try:
            self.isprivate = lambda *args: 0
            # Run the tests by alpha order of names, for consistency in
            # verbose-mode output.
            keys = d.keys()
            keys.sort()
            for k in keys:
                v = d[k]
                thisname = prefix + k
                if type(v) in _StringTypes:
                    f, t = self.runstring(v, thisname)
                elif _isfunction(v) or _isclass(v) or _ismethod(v):
                    f, t = self.rundoc(v, thisname)
                else:
                    raise TypeError("Tester.run__test__: values in "
                            "dict must be strings, functions, methods, "
                            "or classes; " + `v`)
                failures = failures + f
                tries = tries + t
        finally:
            self.isprivate = savepvt
        return failures, tries
示例#2
0
def ismethod(x):
    from inspect import ismethod as _ismethod
    if _ismethod(x) or isinstance(x, (types.MethodType, types.FunctionType,
                    types.UnboundMethodType)) or str(type(x)) in [
                    "<type 'classmethod'>", "<type 'staticmethod'>"]:
        return True
    else:
        return False
def ismethod(x):
    from inspect import ismethod as _ismethod
    if _ismethod(x) or isinstance(
            x,
        (types.MethodType, types.FunctionType,
         types.UnboundMethodType)) or str(
             type(x)) in ["<type 'classmethod'>", "<type 'staticmethod'>"]:
        return True
    else:
        return False
    def get_status(self):
        if hasattr(self, '_status') and self._status is not None:
            return self._status

        if(self._terminated):
            return self._status

        # if pid still exists then return 'Running'
        # else if check process exit code in exec dir
        if _psutil.pid_exists(self._pid):
            proc = _psutil.Process(pid=self._pid)
            if _isfunction(proc.status) or _ismethod(proc.status):
                status = str(proc.status()).capitalize()
            else:
                status = str(proc.status).capitalize()
            if status in ['Zombie']:
                return self._get_status()
            elif status in ['Sleeping', 'Disk-sleep']:
                return 'Running'
            else:
                return status
        else:
            return self._get_status()