'Return a DocTest for the given object, if it defines a docstring;
otherwise, return None.'

def _get_test(self, obj, name, module, globs, source_lines):

    if isinstance(obj, str):
        docstring = obj
    else:
        try:
            if (obj.__doc__ is None):
                docstring = ''
            else:
                docstring = obj.__doc__
                if (not isinstance(docstring, str)):
                    docstring = str(docstring)
        except (TypeError, AttributeError):
            docstring = ''
    lineno = self._find_lineno(obj, source_lines)
    if (self._exclude_empty and (not docstring)):
        return None
    if (module is None):
        filename = None
    else:
        filename = getattr(module, '__file__', module.__name__)
        if (filename[(-4):] in ('.pyc', '.pyo')):
            filename = filename[:(-1)]
    return self._parser.get_doctest(docstring, globs, name, filename, lineno)
