Skip to content

Commit

Permalink
Fix imports and remaining tests
Browse files Browse the repository at this point in the history
  • Loading branch information
astrofrog committed Aug 11, 2023
1 parent 02910f8 commit 28f27ef
Show file tree
Hide file tree
Showing 11 changed files with 27 additions and 31 deletions.
2 changes: 1 addition & 1 deletion doc/customizing_guide/customization.rst
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ that will get called when the preferences dialog is closed. This method should
then set any settings appropriately in the application state. The following is
an example of a custom preference pane::

from glue.config import settings, preference_panes
from glue_qt.config import settings, preference_panes
from qtpy import QtWidgets


Expand Down
6 changes: 3 additions & 3 deletions glue_qt/app/qt/feedback.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
Widgets for sending feedback reports
"""
import os
import pkg_resources

from qtpy import QtGui, QtWidgets
from urllib.parse import urlencode
from urllib.request import Request, urlopen
from glue_qt.utils.qt import load_ui
from glue._deps import get_status_as_odict


__all__ = ['submit_bug_report', 'submit_feedback']
Expand All @@ -18,8 +18,8 @@ def diagnostics():
Return a some system informaton useful for debugging
"""
versions = ""
for package, version in get_status_as_odict().items():
versions += "* {0}: {1}\n".format(package, version)
for pkg in pkg_resources.working_set:
versions += "* {0}: {1}\n".format(pkg.key, pkg.version)
return versions.strip()


Expand Down
2 changes: 1 addition & 1 deletion glue_qt/app/qt/preferences.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def __init__(self, application, parent=None):

self.panes = []

from glue.config import preference_panes
from glue_qt.config import preference_panes
for label, widget_cls in sorted(preference_panes):
pane = widget_cls()
self.ui.tab_widget.addTab(pane, label)
Expand Down
2 changes: 1 addition & 1 deletion glue_qt/app/qt/tests/test_application.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ def test_subset_facet(self):

act = self.app._layer_widget._actions['facet']
self.app.data_collection.append(Data(x=[1, 2, 3]))
with patch('glue.dialogs.subset_facet.qt.SubsetFacetDialog.exec_'):
with patch('glue_qt.dialogs.subset_facet.qt.SubsetFacetDialog.exec_'):
act._do_action()

def test_move_viewer_to_tab(self):
Expand Down
2 changes: 1 addition & 1 deletion glue_qt/app/qt/tests/test_preferences.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ def finalize(self):

preference_panes = [('Custom', CustomPreferences)]

with patch('glue.config.preference_panes', preference_panes):
with patch('glue_qt.config.preference_panes', preference_panes):

dialog = PreferencesDialog(self.app)
dialog.show()
Expand Down
4 changes: 2 additions & 2 deletions glue_qt/app/qt/versions.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import pkg_resources

from glue import __version__

Expand All @@ -7,7 +8,6 @@

from glue.utils import nonpartial
from glue_qt.utils.qt import load_ui, CenteredDialog
from glue._deps import get_status_as_odict

__all__ = ['QVersionsDialog']

Expand All @@ -31,7 +31,7 @@ def __init__(self, *args, **kwargs):
self.ui.button_copy.clicked.connect(nonpartial(self._copy))

def _update_deps(self):
status = get_status_as_odict()
status = {pkg.key: pkg.version for pkg in pkg_resources.working_set}
self._text = ""
for name, version in [('Glue', __version__)] + list(status.items()):
QtWidgets.QTreeWidgetItem(self.ui.version_tree.invisibleRootItem(),
Expand Down
7 changes: 0 additions & 7 deletions glue_qt/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,6 @@ def pytest_configure(config):
load_plugins()


def pytest_report_header(config):
from glue import __version__
glue_version = "%20s:\t%s" % ("glue", __version__)
from glue._deps import get_status
return os.linesep + glue_version + os.linesep + os.linesep + get_status()


def pytest_unconfigure(config):

os.environ.pop('GLUE_TESTING')
Expand Down
2 changes: 1 addition & 1 deletion glue_qt/dialogs/subset_facet/qt/tests/test_subset_facet.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from ..subset_facet import SubsetFacetDialog


patched_facet = patch('glue.dialogs.subset_facet.qt.subset_facet.facet_subsets')
patched_facet = patch('glue_qt.dialogs.subset_facet.qt.subset_facet.facet_subsets')


class TestSubsetFacet(object):
Expand Down
20 changes: 10 additions & 10 deletions glue_qt/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,9 @@ def start_glue(gluefile=None, config=None, datafiles=None, maximized=True,
except ImportError: # Not all PyQt installations have this module
pass

from glue.utils.qt.decorators import die_on_error
from glue_qt.utils.qt.decorators import die_on_error

from glue.utils.qt import get_qapp
from glue_qt.utils.qt import get_qapp
app = get_qapp()

splash = get_splash()
Expand All @@ -155,7 +155,7 @@ def start_glue(gluefile=None, config=None, datafiles=None, maximized=True,
# plugins.
load_plugins(splash=splash, require_qt_plugins=True)

from glue.app.qt import GlueApplication
from glue_qt.app.qt import GlueApplication

datafiles = datafiles or []

Expand Down Expand Up @@ -206,7 +206,7 @@ def execute_script(script):

def get_splash():
"""Instantiate a splash screen"""
from glue.app.qt.splash_screen import QtSplashScreen
from glue_qt.app.qt.splash_screen import QtSplashScreen
splash = QtSplashScreen()
return splash

Expand Down Expand Up @@ -261,12 +261,12 @@ def main(argv=sys.argv):
'glue.io.formats.fits']


REQUIRED_PLUGINS_QT = ['glue.plugins.tools.pv_slicer.qt',
'glue.viewers.image.qt',
'glue.viewers.scatter.qt',
'glue.viewers.histogram.qt',
'glue.viewers.profile.qt',
'glue.viewers.table.qt']
REQUIRED_PLUGINS_QT = ['glue_qt.plugins.tools.pv_slicer.qt',
'glue_qt.viewers.image.qt',
'glue_qt.viewers.scatter.qt',
'glue_qt.viewers.histogram.qt',
'glue_qt.viewers.profile.qt',
'glue_qt.viewers.table.qt']


def load_plugins(splash=None, require_qt_plugins=False):
Expand Down
7 changes: 5 additions & 2 deletions glue_qt/utils/qt/dialogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,10 @@ def center(self):
# Adapted from StackOverflow
# https://stackoverflow.com/questions/20243637/pyqt4-center-window-on-active-screen
frameGm = self.frameGeometry()
screen = QtWidgets.QApplication.desktop().screenNumber(QtWidgets.QApplication.desktop().cursor().pos())
centerPoint = QtWidgets.QApplication.desktop().screenGeometry(screen).center()
try:
screen = QtWidgets.QApplication.desktop().screenNumber(QtWidgets.QApplication.desktop().cursor().pos())
centerPoint = QtWidgets.QApplication.desktop().screenGeometry(screen).center()
except AttributeError:
centerPoint = QtWidgets.QApplication.primaryScreen().geometry().center()
frameGm.moveCenter(centerPoint)
self.move(frameGm.topLeft())
4 changes: 2 additions & 2 deletions glue_qt/utils/qt/tests/test_dialogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ class Bar:

Bar.LABEL = 'Baz'

with mock.patch('glue.utils.qt.dialogs.pick_item') as d:
with mock.patch('glue_qt.utils.qt.dialogs.pick_item') as d:
pick_class([Foo, Bar], default=Foo)
d.assert_called_once_with([Foo, Bar], ['Foo', 'Baz'], default=Foo)

with mock.patch('glue.utils.qt.dialogs.pick_item') as d:
with mock.patch('glue_qt.utils.qt.dialogs.pick_item') as d:
pick_class([Foo, Bar], sort=True)
d.assert_called_once_with([Bar, Foo], ['Baz', 'Foo'])

Expand Down

0 comments on commit 28f27ef

Please sign in to comment.