def test_remove_dock_widget(): with pytest_hackedit.MainWindow(PROJ_PATH): editor.open_file(FILE1) dw = window.add_dock_widget(QtWidgets.QPushButton(), 'FooDock2', QtGui.QIcon.fromTheme('document-save'), QtCore.Qt.BottomDockWidgetArea) window.remove_dock_widget(dw)
def test_open_proj_new_window(): with pytest_hackedit.MainWindow(PATH1, remove_project_folder=True) as w: settings.set_open_mode(settings.OpenMode.NEW_WINDOW) assert len(project.get_projects()) == 1 project.open_project(PATH2, sender=w) assert len(w.instance.app.editor_windows) == 2 assert len(project.get_projects()) == 1 pytest_hackedit.app().editor_windows[-1].close()
def test_open_proj_current_window(): with pytest_hackedit.MainWindow(PATH1, remove_project_folder=True) as w: settings.set_open_mode(settings.OpenMode.CURRENT_WINDOW) assert settings.open_mode() == settings.OpenMode.CURRENT_WINDOW assert len(project.get_projects()) == 1 project.open_project(PATH2, sender=w.instance) assert len(project.get_projects()) == 2 QtTest.QTest.qWait(1000)
def test_get_dock_widget(): with pytest_hackedit.MainWindow(PROJ_PATH): editor.open_file(FILE1) dw = window.add_dock_widget(QtWidgets.QPushButton(), 'FooDock', QtGui.QIcon.fromTheme('document-save'), QtCore.Qt.BottomDockWidgetArea) ret_val = window.get_dock_widget('FooDock') assert ret_val == dw
def test_get_plugin_instance(qtbot): from hackedit.plugins.outline import DocumentOutline with pytest_hackedit.MainWindow(PROJ_PATH): p = plugins.get_plugin_instance(DocumentOutline) assert p is not None assert isinstance(p, DocumentOutline) with pytest.raises(TypeError): p = plugins.get_plugin_instance(qtbot)
def test_add_dock_widget(): with pytest_hackedit.MainWindow(PROJ_PATH): editor.open_file(FILE1) dw = window.add_dock_widget(QtWidgets.QPushButton(), 'FooDock', QtGui.QIcon.fromTheme('document-save'), QtCore.Qt.BottomDockWidgetArea) assert dw is not None assert isinstance(dw, QtWidgets.QDockWidget)
def test_scriptrunnerplugin(qtbot): def click_cancel(): qtbot.keyPress(QtWidgets.qApp.activeWindow(), QtCore.Qt.Key_Escape) # not really a unit test, kinda functional with pytest_hackedit.MainWindow(PROJ_PATH) as w: p = FakeScriptRunnerPlugin(w.instance) p.enable_mnu_configs() p.enable_run()
def test_start_no_thread(): global finished with pytest_hackedit.MainWindow(PROJ_PATH): finished = False t = tasks.start('Sample task', echo, callback=callback, use_thread=False) assert t is not None while not finished: QtTest.QTest.qWait(100)
def test_plugin_load_error_event(): with pytest_hackedit.MainWindow(PROJ_PATH) as w: try: print(10 / 0) except Exception as e: e = events.PluginLoadErrorEvent("Unhandled exception", str(e), e) assert e.traceback != '' assert len(e.custom_actions) == 2 events.post(e, show_balloon=True, force_show=True) events.post(e) assert e.main_window == w.instance QtCore.QTimer.singleShot(1000, cancel_dialog) e.report_bug()
def test_connect_slot(signal): def slot(): pass with pytest_hackedit.MainWindow(PROJ_PATH): signals.connect_slot(signal, slot) signals.disconnect_slot(signal, slot)
def test_add_statusbar_widget(): with pytest_hackedit.MainWindow(PROJ_PATH): lbl = QtWidgets.QLabel() window.add_statusbar_widget(lbl)
def test_get_project_treeview(): with pytest_hackedit.MainWindow(PROJ_PATH): assert isinstance(window.get_project_treeview(), FileSystemTreeView)
def test_get_menu(): with pytest_hackedit.MainWindow(PROJ_PATH): mnu = window.get_menu(_('Edit')) assert mnu is not None assert isinstance(mnu, QtWidgets.QMenu)
def test_add__action(): with pytest_hackedit.MainWindow(PROJ_PATH) as w: window.add_action(QtWidgets.QAction('Test', w.instance))
def test_get_toolbar(): with pytest_hackedit.MainWindow(PROJ_PATH): tb = window.get_toolbar('toolBarFile', 'FileToolBar') assert isinstance(tb, QtWidgets.QToolBar)
def test_get_main_window(): with pytest_hackedit.MainWindow(PROJ_PATH) as w: assert w.instance == window.get_main_window()
def test_add_project(): with pytest_hackedit.MainWindow(PATH1, remove_project_folder=True): assert len(project.get_projects()) == 1 project.add_project(PATH2) assert len(project.get_projects()) == 2
def test_get_tab_under_context_menu(): with pytest_hackedit.MainWindow(PROJ_PATH): editor.open_file(FILE1) assert window.get_tab_under_context_menu() is None
def test_add_tab_widget_context_menu_action(): with pytest_hackedit.MainWindow(PROJ_PATH) as w: window.add_tab_widget_context_menu_action( QtWidgets.QAction('Test', w.instance))