Skip to content

Commit

Permalink
Move import in conftest.py inside functions
Browse files Browse the repository at this point in the history
As a side-effect of PR spyder-ide/spyder#21734, a QApplication needs
to be running before importing
spyder.plugins.preferences.widgets.configdialog. Moving the import
inside a function achieves this.
  • Loading branch information
jitseniesen committed May 28, 2024
1 parent 00c6edf commit 947673f
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion spyder_notebook/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,17 @@
from spyder.api.plugin_registration.registry import PLUGIN_REGISTRY
from spyder.app.cli_options import get_options
from spyder.config.manager import CONF
from spyder.plugins.preferences.plugin import Preferences
from spyder.utils.icon_manager import ima


class MainWindowMock(QMainWindow):
register_shortcut = Mock()

def __init__(self, parent):
# This import assumes that an QApplication is already running,
# so we can not put it at the top of the file
from spyder.plugins.preferences.plugin import Preferences

super().__init__(parent)
self.default_style = None
self.widgetlist = []
Expand Down Expand Up @@ -76,6 +79,10 @@ def get_plugin(self, plugin_name, error=True):
class ConfigDialogTester(QWidget):
def __init__(self, parent, main_class,
general_config_plugins, plugins):
# This import assumes that an QApplication is already running,
# so we can not put it at the top of the file
from spyder.plugins.preferences.plugin import Preferences

super().__init__(parent)
self._main = main_class(self) if main_class else None
if self._main is None:
Expand Down

0 comments on commit 947673f

Please sign in to comment.