Skip to content

Commit

Permalink
Move import inside one test inside a function
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 Apr 8, 2024
1 parent 7b921ae commit 433cc34
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion spyder_unittest/widgets/tests/test_confpage.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
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

# Local imports
from spyder_unittest.unittestplugin import UnitTestPlugin
Expand All @@ -34,6 +33,10 @@ 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 @@ -75,6 +78,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 433cc34

Please sign in to comment.