'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):

    lineno = None
    if isinstance(obj, string_types):
        docstring = obj
        matches = re.findall('line    \\d+', name)
        assert (len(matches) == 1), ("string    '%s'    does    not    contain    lineno    " % name)
        lineno = int(matches[0][5:])
    else:
        try:
            if (obj.__doc__ is None):
                docstring = ''
            else:
                docstring = obj.__doc__
                if (not isinstance(docstring, string_types)):
                    docstring = str(docstring)
        except (TypeError, AttributeError):
            docstring = ''
    if (self._exclude_empty and (not docstring)):
        return None
    if isinstance(obj, property):
        if (obj.fget.__doc__ is None):
            return None
    if (lineno is None):
        if (hasattr(obj, 'func_closure') and (obj.func_closure is not None)):
            tobj = obj.func_closure[0].cell_contents
        elif isinstance(obj, property):
            tobj = obj.fget
        else:
            tobj = obj
        lineno = self._find_lineno(tobj, source_lines)
    if (lineno is None):
        return None
    if (module is None):
        filename = None
    else:
        filename = getattr(module, '__file__', module.__name__)
        if (filename[(-4):] in ('.pyc', '.pyo')):
            filename = filename[:(-1)]
    if hasattr(obj, '_doctest_depends_on'):
        globs['_doctest_depends_on'] = obj._doctest_depends_on
    else:
        globs['_doctest_depends_on'] = {}
    return self._parser.get_doctest(docstring, globs, name, filename, lineno)
