def test_remove_package(self):
        """ Tests if the package really gets deleted, and that it gets
            selected again in the available packages list.
        """
        
        pkg = "URL"
        _app = get_vistrails_application()
        builder = _app.builderWindow
        builder.showPreferences()
        prefs = builder.preferencesDialog
        packages = prefs._packages_tab
        prefs._tab_widget.setCurrentWidget(packages)
        QtGui.QApplication.processEvents()

        # check if package is loaded
        av = packages._available_packages_list
        try:
            item, = av.findItems(pkg, QtCore.Qt.MatchExactly)
            av.setCurrentItem(item)
            QtGui.QApplication.processEvents()
            QtGui.QApplication.processEvents()
            packages.enable_current_package()
        except ValueError:
            # Already enabled
            pass
        QtGui.QApplication.processEvents()
        QtGui.QApplication.processEvents()

        inst = packages._enabled_packages_list
        item, = inst.findItems(pkg, QtCore.Qt.MatchExactly)
        inst.setCurrentItem(item)
        QtGui.QApplication.processEvents()
        QtGui.QApplication.processEvents()
        packages.disable_current_package()
        QtGui.QApplication.processEvents()
        QtGui.QApplication.processEvents()

        # force delayed calls
        packages.populate_lists()
        packages.select_package_after_update_slot(pkg)
        QtGui.QApplication.processEvents()
        QtGui.QApplication.processEvents()

        # This does not work because the selection is delayed
        av = packages._available_packages_list
        items = av.selectedItems()
        self.assertEqual(len(items), 1, "No available items selected!")
        self.assertEqual(items[0].text(), unicode(pkg),
                         "Wrong available item selected: %s" % items[0].text())

        # check if configuration has been written correctly
        startup = _app.startup
        self.assertIn(pkg, startup.disabled_packages)
        self.assertNotIn(pkg, startup.enabled_packages)
dataset/ETHPy150Open VisTrails/VisTrails/vistrails/gui/preferences.py/TestPreferencesDialog.test_remove_package/original