diff --git a/a00_qpip/plugin.py b/a00_qpip/plugin.py index 17f5d51..0859e60 100644 --- a/a00_qpip/plugin.py +++ b/a00_qpip/plugin.py @@ -26,7 +26,7 @@ def __init__(self, iface, plugin_path=None): self._defered_packages = [] self.settings = QgsSettings() self.settings.beginGroup("QPIP") - + if plugin_path is None: self.plugins_path = os.path.join( QgsApplication.qgisSettingsDirPath(), "python", "plugins" @@ -74,9 +74,7 @@ def initGui(self): def initComplete(self): if self._defered_packages: log(f"Initialization complete. Loading deferred packages") - dialog, run_gui = self.check_deps( - additional_plugins=self._defered_packages - ) + dialog, run_gui = self.check_deps(additional_plugins=self._defered_packages) if run_gui: self.promt_install(dialog) self.save_settings(dialog) @@ -98,7 +96,9 @@ def unload(self): os.environ["PYTHONPATH"] = os.environ["PYTHONPATH"].replace( self.bin_path + os.pathsep, "" ) - os.environ["PATH"] = os.environ["PATH"].replace(self.bin_path + os.pathsep, "") + os.environ["PATH"] = os.environ["PATH"].replace( + self.bin_path + os.pathsep, "" + ) def patched_load_plugin(self, packageName): """ @@ -183,7 +183,7 @@ def check_deps(self, additional_plugins=[]) -> MainDialog | bool: libs.values(), self._check_on_startup(), self._check_on_install() ) return dialog, needs_gui - + def promt_install(self, dialog: MainDialog): """Promts the install dialog and ask the user what to install""" if dialog.exec_(): @@ -196,7 +196,7 @@ def promt_install(self, dialog: MainDialog): if reqs_to_install: log(f"Will install selected dependencies : {reqs_to_install}") self.pip_install_reqs(reqs_to_install) - + def save_settings(self, dialog): """Stores the settings values""" sys.path_importer_cache.clear() diff --git a/tests/test_finding_req.py b/tests/test_finding_req.py index 08c148a..6a9c41d 100644 --- a/tests/test_finding_req.py +++ b/tests/test_finding_req.py @@ -7,36 +7,40 @@ from a00_qpip.plugin import Plugin + class initializationCompleted: def connect(self): pass + def popWidget(): return True + THIS_DIR = os.path.dirname(__file__) + @pytest.fixture() def plugin(qgis_iface): qgis_iface.initializationCompleted = initializationCompleted qgis_iface.messageBar().popWidget = popWidget - plugin = Plugin(qgis_iface, '.') + plugin = Plugin(qgis_iface, ".") yield plugin def test_plugin_a(plugin: Plugin): - plugin_a = os.path.join(THIS_DIR, '..', 'test_plugins', 'plugin_a') + plugin_a = os.path.join(THIS_DIR, "..", "test_plugins", "plugin_a") dialog, needs_gui = plugin.check_deps([plugin_a]) libs = dialog.reqs_to_install assert len(libs) == 2 - assert libs[0] == 'cowsay==4.0' + assert libs[0] == "cowsay==4.0" assert needs_gui def test_plugin_b(plugin: Plugin): - plugin_b = os.path.join(THIS_DIR, '..', 'test_plugins', 'plugin_b') + plugin_b = os.path.join(THIS_DIR, "..", "test_plugins", "plugin_b") dialog, needs_gui = plugin.check_deps([plugin_b]) libs = dialog.reqs_to_install assert len(libs) == 2 - assert libs[0] == 'cowsay==5.0' + assert libs[0] == "cowsay==5.0" assert needs_gui