-
-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix failing tests on latest after widget-base Qt6 PR was merged #5921
Closed
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Well, it seems that we would have to release widget-base for this to work... Any other ideas or should we just release widget base and then (perhaps) merge this PR? @ales-erjavec, @janezd? |
How about this instead diff --git a/Orange/widgets/evaluate/tests/test_owpredictions.py b/Orange/widgets/evaluate/tests/test_owpredictions.py
index 302e7f5b9..1214d0041 100644
--- a/Orange/widgets/evaluate/tests/test_owpredictions.py
+++ b/Orange/widgets/evaluate/tests/test_owpredictions.py
@@ -28,7 +28,7 @@ from Orange.data import Table, Domain, DiscreteVariable, ContinuousVariable
from Orange.modelling import ConstantLearner, TreeLearner
from Orange.evaluation import Results
from Orange.widgets.tests.utils import excepthook_catch, \
- possible_duplicate_table
+ possible_duplicate_table, simulate
from Orange.widgets.utils.colorpalettes import LimitedDiscretePalette
@@ -871,8 +871,7 @@ class TestOWPredictions(WidgetTest):
self.assertEqual(float(table.model.data(table.model.index(0, 3))), 42)
for idx, value in enumerate(widget.class_var.values):
- combo.setCurrentText(value)
- combo.activated[str].emit(value)
+ simulate.combobox_activate_item(combo, value, Qt.DisplayRole)
self.assertEqual(table.model.rowCount(), 1)
self.assertEqual(table.model.columnCount(), 4)
self.assertEqual(float(table.model.data(table.model.index(0, 3))),
diff --git a/Orange/widgets/model/tests/test_owcalibratedlearner.py b/Orange/widgets/model/tests/test_owcalibratedlearner.py
index 7bf9574c5..915ab2282 100644
--- a/Orange/widgets/model/tests/test_owcalibratedlearner.py
+++ b/Orange/widgets/model/tests/test_owcalibratedlearner.py
@@ -9,6 +9,7 @@ from Orange.data import Table
from Orange.widgets.model.owcalibratedlearner import OWCalibratedLearner
from Orange.widgets.tests.base import WidgetTest, WidgetLearnerTestMixin, \
datasets
+from Orange.widgets.tests.utils import qbuttongroup_emit_clicked
class TestOWCalibratedLearner(WidgetTest, WidgetLearnerTestMixin):
@@ -140,16 +141,16 @@ class TestOWCalibratedLearner(WidgetTest, WidgetLearnerTestMixin):
widget.calibration = widget.IsotonicCalibration
widget.threshold = widget.OptimizeCA
- widget.controls.calibration.group.buttonClicked[int].emit(
- widget.IsotonicCalibration)
+ qbuttongroup_emit_clicked(widget.controls.calibration.group,
+ widget.IsotonicCalibration)
learner = self.get_output(widget.Outputs.learner)
self.assertEqual(learner.name, "Foo + Isotonic + CA")
widget.calibration = widget.NoCalibration
widget.threshold = widget.OptimizeCA
- widget.controls.calibration.group.buttonClicked[int].emit(
- widget.NoCalibration)
+ qbuttongroup_emit_clicked(widget.controls.calibration.group,
+ widget.NoCalibration)
learner = self.get_output(widget.Outputs.learner)
self.assertEqual(learner.name, "Foo + CA")
diff --git a/Orange/widgets/tests/utils.py b/Orange/widgets/tests/utils.py
index b7bf94ceb..f5f5db992 100644
--- a/Orange/widgets/tests/utils.py
+++ b/Orange/widgets/tests/utils.py
@@ -4,10 +4,12 @@ from functools import wraps
import warnings
import contextlib
-from AnyQt.QtCore import Qt, QObject, QEventLoop, QTimer, QLocale, QPoint
+from AnyQt.QtCore import (
+ Qt, QObject, QEventLoop, QTimer, QLocale, QPoint, QT_VERSION_INFO
+)
from AnyQt.QtTest import QTest
from AnyQt.QtGui import QMouseEvent, QContextMenuEvent
-from AnyQt.QtWidgets import QApplication, QWidget
+from AnyQt.QtWidgets import QApplication, QWidget, QButtonGroup, QComboBox
from Orange.data import Table, Domain, ContinuousVariable
@@ -229,12 +231,10 @@ class simulate:
mindex = model.index(index, column, root)
assert mindex.flags() & Qt.ItemIsEnabled
cbox.setCurrentIndex(index)
- text = cbox.currentText()
# QComboBox does not have an interface which would allow selecting
# the current item as if a user would. Only setCurrentIndex which
# does not emit the activated signals.
- cbox.activated[int].emit(index)
- cbox.activated[str].emit(text)
+ qcombobox_emit_activated(cbox, index)
if delay >= 0:
QTest.qWait(delay)
@@ -293,6 +293,24 @@ class simulate:
simulate.combobox_activate_index(cbox, index, delay)
+def qcombobox_emit_activated(cb: QComboBox, index: int):
+ cb.activated[int].emit(index)
+ text = cb.itemText(index)
+ if QT_VERSION_INFO >= (5, 15):
+ cb.textActivated.emit(text)
+ if QT_VERSION_INFO < (6, 0):
+ cb.activated[str].emit(text)
+
+
+def qbuttongroup_emit_clicked(bg: QButtonGroup, id):
+ button = bg.button(id)
+ bg.buttonClicked.emit(button)
+ if QT_VERSION_INFO >= (5, 15):
+ bg.idClicked.emit(id)
+ if QT_VERSION_INFO < (6, 0):
+ bg.buttonClicked[int].emit(id)
+
+
def override_locale(language):
"""Execute the wrapped code with a different locale."""
def wrapper(f):
diff --git a/Orange/widgets/visualize/tests/test_ownomogram.py b/Orange/widgets/visualize/tests/test_ownomogram.py
index 87bb0e07c..6069eca8f 100644
--- a/Orange/widgets/visualize/tests/test_ownomogram.py
+++ b/Orange/widgets/visualize/tests/test_ownomogram.py
@@ -14,7 +14,7 @@ from Orange.classification import (
from Orange.preprocess import Scale, Continuize
from Orange.tests import test_filename
from Orange.widgets.tests.base import WidgetTest
-from Orange.widgets.tests.utils import simulate
+from Orange.widgets.tests.utils import simulate, qbuttongroup_emit_clicked
from Orange.widgets.visualize.ownomogram import (
OWNomogram, DiscreteFeatureItem, ContinuousFeatureItem, ProbabilitiesDotItem,
MovableToolTip
@@ -240,7 +240,7 @@ class TestOWNomogram(WidgetTest):
# Set to output all
self.widget.display_index = 0
- self.widget.controls.display_index.group.buttonClicked[int].emit(0)
+ qbuttongroup_emit_clicked(self.widget.controls.display_index.group, 0)
attrs = self.get_output(self.widget.Outputs.features)
self.assertEqual(attrs, [age, sex, status])
|
@ales-erjavec, if you already wrote it, could you just make a PR? Thanks. :) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue
Three tests are failing after merging biolab/orange-widget-base#187.
Description of changes
Aims to fix failing tests by cherry-picking two commits from the PyQt6 PR: #5884.
Includes