Exemple #1
0
def test_codeinfo():
    """Test CodeInfo."""
    code = 'import numpy'
    test = CodeInfo('test', code, len(code) - 2)
    assert test.obj == 'num'
    assert test.full_obj == 'numpy'
    test2 = CodeInfo('test', code, len(code) - 2)
    assert test == test2
    test3 = pickle.loads(pickle.dumps(test2.__dict__))
    assert test3['full_obj'] == 'numpy'    
Exemple #2
0
    def _get_code_info(self, name, position=None, **kwargs):

        editor = self.editor_widget.get_current_editor()
        finfo = self.editor_widget.get_current_finfo()
        in_comment_or_string = editor.in_comment_or_string()

        if position is None:
            position = editor.get_position('cursor')

        kwargs['editor'] = editor
        kwargs['finfo'] = finfo
        kwargs['editor_widget'] = self.editor_widget

        return CodeInfo(name, finfo.get_source_code(), position,
                        finfo.filename, editor.is_python_like,
                        in_comment_or_string, **kwargs)