Exemple #1
0
def test_dochelpers():
    """Test dochelpers."""
    assert not getargtxt(Test.__init__)
    if PY2:                    
        assert getargtxt(Test.method) == ['x, ', 'y=2']
        assert getdoc(sorted) == {'note': 'Function of __builtin__ module',
                                  'argspec': u'(iterable, cmp=None, key=None, '
                                              'reverse=False)',
                                  'docstring': u'sorted(iterable, cmp=None, '
                                                'key=None, reverse=False) --> '
                                                'new sorted list',
                                  'name': 'sorted'}
        assert getargtxt(sorted) == ['iterable, ', ' cmp=None, ',
                                     ' key=None, ', ' reverse=False']
    else:
        assert not getargtxt(Test.method)
        if os.name == 'nt':
            assert getdoc(sorted) == {'note': 'Function of builtins module',
                                      'argspec': '(...)',
                                      'docstring': 'Return a new list '
                                                   'containing '
                                                   'all items from the '
                                                   'iterable in ascending '
                                                   'order.\n\nA custom '
                                                   'key function can be '
                                                   'supplied to customise the '
                                                   'sort order, and '
                                                   'the\nreverse flag can be '
                                                   'set to request the result '
                                                   'in descending order.',
                                      'name': 'sorted'}
        else:
            assert getdoc(sorted) == {'note': 'Function of builtins module',
                                      'argspec': '(...)',
                                      'docstring': 'Return a new list '
                                                   'containing '
                                                   'all items from the '
                                                   'iterable in ascending '
                                                   'order.\n\nA custom '
                                                   'key function can be '
                                                   'supplied to customize the '
                                                   'sort order, and '
                                                   'the\nreverse flag can be '
                                                   'set to request the result '
                                                   'in descending order.',
                                      'name': 'sorted'}
        assert not getargtxt(sorted)
    assert isdefined('numpy.take', force_import=True)
    assert isdefined('__import__')
    assert not isdefined('.keys', force_import=True)
    assert getobj('globals') == 'globals'
    assert not getobj('globals().keys')
    assert getobj('+scipy.signal.') == 'scipy.signal'
    assert getobj('4.') == '4'
    def get_doc(self, objtxt):
        """Get object documentation dictionary"""
        try:
            import matplotlib
            matplotlib.rcParams['docstring.hardcopy'] = True
        except:
            pass

        if not IS_EXT_INTERPRETER:
            from spyder.utils.dochelpers import getdoc
        else:
            from utils.dochelpers import getdoc

        obj, valid = self._eval(objtxt)
        if valid:
            return getdoc(obj)
Exemple #3
0
    def get_doc(self, objtxt):
        """Get object documentation dictionary"""
        try:
            import matplotlib
            matplotlib.rcParams['docstring.hardcopy'] = True
        except:
            pass

        if not IS_EXT_INTERPRETER:
            from spyder.utils.dochelpers import getdoc
        else:
            from utils.dochelpers import getdoc

        obj, valid = self._eval(objtxt)
        if valid:
            return getdoc(obj)
Exemple #4
0
 def get_doc(self, objtxt):
     """Get object documentation dictionary"""
     obj, valid = self._eval(objtxt)
     if valid:
         return getdoc(obj)
Exemple #5
0
def test_dochelpers():
    """Test dochelpers."""
    assert not getargtxt(Test.__init__)
    if PY2:
        assert getargtxt(Test.method) == ['x, ', 'y=2']
        assert getdoc(sorted) == {
            'note':
            'Function of __builtin__ module',
            'argspec':
            u'(iterable, cmp=None, key=None, '
            'reverse=False)',
            'docstring':
            u'sorted(iterable, cmp=None, '
            'key=None, reverse=False) --> '
            'new sorted list',
            'name':
            'sorted'
        }
        assert getargtxt(sorted) == [
            'iterable, ', ' cmp=None, ', ' key=None, ', ' reverse=False'
        ]
    else:
        assert not getargtxt(Test.method)
        if os.name == 'nt':
            assert getdoc(sorted) == {
                'note':
                'Function of builtins module',
                'argspec':
                '(...)',
                'docstring':
                'Return a new list '
                'containing '
                'all items from the '
                'iterable in ascending '
                'order.\n\nA custom '
                'key function can be '
                'supplied to customise the '
                'sort order, and '
                'the\nreverse flag can be '
                'set to request the result '
                'in descending order.',
                'name':
                'sorted'
            }
        else:
            assert getdoc(sorted) == {
                'note':
                'Function of builtins module',
                'argspec':
                '(...)',
                'docstring':
                'Return a new list '
                'containing '
                'all items from the '
                'iterable in ascending '
                'order.\n\nA custom '
                'key function can be '
                'supplied to customize the '
                'sort order, and '
                'the\nreverse flag can be '
                'set to request the result '
                'in descending order.',
                'name':
                'sorted'
            }
        assert not getargtxt(sorted)
    assert isdefined('numpy.take', force_import=True)
    assert isdefined('__import__')
    assert not isdefined('.keys', force_import=True)
    assert getobj('globals') == 'globals'
    assert not getobj('globals().keys')
    assert getobj('+scipy.signal.') == 'scipy.signal'
    assert getobj('4.') == '4'
Exemple #6
0
 def get_builtin_doc(self, pyobject):
     buitin = pyobject.builtin
     return getdoc(buitin)
Exemple #7
0
 def get_doc(self, objtxt):
     """Get object documentation dictionary"""
     obj, valid = self._eval(objtxt)
     if valid:
         return getdoc(obj)
Exemple #8
0
 def get_builtin_doc(self, pyobject):
     buitin = pyobject.builtin
     return getdoc(buitin)