Пример #1
0
def test_dochelpers():
    """Test dochelpers."""
    assert getargtxt(Test.method) == ['x, ', 'y=2']
    assert not getargtxt(Test.__init__)

    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\n'
        'reverse 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('zzz', force_import=True)

    assert getobj('globals') == 'globals'
    assert not getobj('globals().keys')
    assert getobj('+scipy.signal.') == 'scipy.signal'
    assert getobj('4.') == '4'
Пример #2
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'
Пример #3
0
    def is_defined(self, obj, force_import=False):
        """Return True if object is defined in current namespace"""
        from spyder_kernels.utils.dochelpers import isdefined

        ns = self._get_current_namespace(with_magics=True)
        return isdefined(obj, force_import=force_import, namespace=ns)
Пример #4
0
 def is_defined(self, objtxt, force_import=False):
     """Return True if object is defined"""
     return isdefined(objtxt,
                      force_import=force_import,
                      namespace=self.locals)
Пример #5
0
 def is_defined(self, objtxt, force_import=False):
     """Return True if object is defined"""
     return isdefined(objtxt, force_import=force_import,
                      namespace=self.locals)