Пример #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'
Пример #2
0
    def is_defined(self, obj, force_import=False):
        """Return True if object is defined in current namespace"""
        if not IS_EXT_INTERPRETER:
            from spyder.utils.dochelpers import isdefined
        else:
            from utils.dochelpers import isdefined

        ns = self._get_current_namespace(with_magics=True)
        return isdefined(obj, force_import=force_import, namespace=ns)
Пример #3
0
    def is_defined(self, obj, force_import=False):
        """Return True if object is defined in current namespace"""
        if not IS_EXT_INTERPRETER:
            from spyder.utils.dochelpers import isdefined
        else:
            from 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, obj, force_import=False):
     """Return True if object is defined in current namespace"""
     ns = self._get_current_namespace(with_magics=True)
     return isdefined(obj, force_import=force_import, namespace=ns)
Пример #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'
Пример #6
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)
Пример #7
0
 def isdefined(self, obj, force_import=False):
     """Return True if object is defined in current namespace"""
     ns = self.get_current_namespace(with_magics=True)
     return isdefined(obj, force_import=force_import, namespace=ns)