Пример #1
0
 def show_syspath(self, syspath):
     """Show sys.path contents."""
     if syspath is not None:
         editor = CollectionsEditor()
         editor.setup(syspath, title="sys.path contents", readonly=True,
                      width=600, icon=ima.icon('syspath'))
         self.dialog_manager.show(editor)
     else:
         return
Пример #2
0
 def show_syspath(self):
     """Show sys.path"""
     editor = CollectionsEditor()
     editor.setup(sys.path,
                  title="sys.path",
                  readonly=True,
                  width=600,
                  icon=ima.icon('syspath'))
     self.dialog_manager.show(editor)
Пример #3
0
def test_view_module_in_coledit():
    """
    Test that modules don't produce an error when opening in Variable Explorer.

    Also check that they are set as readonly. Regression test for issue #6080 .
    """
    editor = CollectionsEditor()
    editor.setup(os, "module_test", readonly=False)
    assert editor.widget.editor.readonly
Пример #4
0
 def show_syspath(self, syspath):
     """Show sys.path contents."""
     if syspath is not None:
         editor = CollectionsEditor()
         editor.setup(syspath, title="sys.path contents", readonly=True,
                      width=600, icon=ima.icon('syspath'))
         self.dialog_manager.show(editor)
     else:
         return
Пример #5
0
def test_pandas_dateoffset_view():
    """
    Test that pandas ``DateOffset`` objs can be viewied in CollectionsEditor.

    Regression test for issue #6729 .
    """
    test_dateoffset = pandas.DateOffset()
    col_editor = CollectionsEditor(None)
    col_editor.setup(test_dateoffset)
    col_editor.show()
    assert col_editor.get_value()
    col_editor.accept()
Пример #6
0
def test_collectionseditor_with_class_having_buggy_copy(qtbot):
    """
    Test that editor for object whose .copy() returns a different type is
    readonly; cf. issue #6936.
    """
    class MyDictWithBuggyCopy(dict):
        pass

    md = MyDictWithBuggyCopy({1: 2})
    editor = CollectionsEditor()
    editor.setup(md)
    assert editor.widget.editor.readonly
Пример #7
0
def test_collectionseditor_with_class_having_correct_copy(qtbot):
    """
    Test that editor for object whose .copy() returns the same type is not
    readonly; cf. issue #6936.
    """
    class MyDictWithCorrectCopy(dict):
        def copy(self):
            return MyDictWithCorrectCopy(self)

    md = MyDictWithCorrectCopy({1: 2})
    editor = CollectionsEditor()
    editor.setup(md)
    assert not editor.widget.editor.readonly
Пример #8
0
def test_edit_nonsettable_objects(qtbot, nonsettable_objects_data):
    """
    Test that errors trying to edit attributes in ColEdit are handled properly.

    Integration regression test for issues #6727 and #6728 .
    """
    for test_obj, expected_obj, keys in nonsettable_objects_data:
        col_editor = CollectionsEditor(None)
        col_editor.setup(test_obj)
        col_editor.show()
        qtbot.waitForWindowShown(col_editor)
        view = col_editor.widget.editor
        indicies = [view.model.get_index_from_key(key) for key in keys]

        for _ in range(3):
            qtbot.keyClick(view, Qt.Key_Right)
        last_row = -1
        rows_to_test = [index.row() for index in indicies]
        for row in rows_to_test:
            for _ in range(row - last_row - 1):
                qtbot.keyClick(view, Qt.Key_Down)
            qtbot.keyClick(view, Qt.Key_Space)
            qtbot.keyClick(view.focusWidget(), Qt.Key_Backspace)
            qtbot.keyClicks(view.focusWidget(), "2")
            qtbot.keyClick(view.focusWidget(), Qt.Key_Down)
            last_row = row

        qtbot.wait(100)
        # Due to numpy's deliberate breakage of __eq__ comparison
        assert all([
            key == "_typ" or (getattr(col_editor.get_value(), key) == getattr(
                expected_obj, key)) for key in keys
        ])

        col_editor.accept()
        qtbot.wait(200)
        # Same reason as above
        assert all([
            key == "_typ" or (getattr(col_editor.get_value(), key) == getattr(
                expected_obj, key)) for key in keys
        ])
        assert all([
            getattr(test_obj, key) == getattr(expected_obj, key)
            for key in keys
        ])
Пример #9
0
def test_xml_dom_element_view():
    """
    Test that XML DOM ``Element``s are able to be viewied in CollectionsEditor.

    Regression test for issue #5642 .
    """
    xml_path = path.join(LOCATION, 'dom_element_test.xml')
    with open(xml_path) as xml_file:
        xml_data = xml_file.read()

    xml_content = parseString(xml_data)
    xml_element = xml_content.getElementsByTagName("note")[0]

    col_editor = CollectionsEditor(None)
    col_editor.setup(xml_element)
    col_editor.show()
    assert col_editor.get_value()
    col_editor.accept()
def test_view_module_in_coledit():
    """Check that modules don't produce an error when trying to open them in
    Variable Explorer, and are set as readonly. Regression test for #6080"""
    editor = CollectionsEditor()
    editor.setup(os, "module_test", readonly=False)
    assert editor.widget.editor.readonly
Пример #11
0
 def show_syspath(self):
     """Show sys.path"""
     editor = CollectionsEditor()
     editor.setup(sys.path, title="sys.path", readonly=True, width=600, icon=ima.icon("syspath"))
     self.dialog_manager.show(editor)
Пример #12
0
def test_view_module_in_coledit():
    """Check that modules don't produce an error when trying to open them in
    Variable Explorer, and are set as readonly. Regression test for #6080"""
    editor = CollectionsEditor()
    editor.setup(os, "module_test", readonly=False)
    assert editor.widget.editor.readonly
Пример #13
0
 def show_syspath(self):
     """Show sys.path contents"""
     editor = CollectionsEditor()
     editor.setup(self.shell.get_syspath(), title="sys.path", readonly=True,
                  width=600, icon=ima.icon('syspath'))
     self.dialog_manager.show(editor)