|
1 | 1 | # Test methods with long descriptive names can omit docstrings |
2 | 2 | # pylint: disable=missing-docstring |
| 3 | +import time |
| 4 | + |
3 | 5 | from AnyQt.QtCore import QLocale, Qt |
4 | 6 | from AnyQt.QtTest import QTest |
5 | 7 | from AnyQt.QtWidgets import QLineEdit, QComboBox |
@@ -259,15 +261,40 @@ def test_change_var_type(self): |
259 | 261 | new_iris = iris.transform(new_domain) |
260 | 262 | self.send_signal(self.widget.Inputs.data, new_iris) |
261 | 263 |
|
262 | | - def test_migration_to_version_1(self): |
263 | | - iris = Table("iris") |
| 264 | + # Uncomment this on 1. 1. 2021 |
| 265 | + # |
| 266 | + # def test_migration_to_version_1(self): |
| 267 | + # iris = Table("iris") |
| 268 | + # |
| 269 | + # ch = SelectRowsContextHandler() |
| 270 | + # context = ch.new_context(iris.domain, *ch.encode_domain(iris.domain)) |
| 271 | + # context.values = dict(conditions=[["petal length", 2, (5.2,)]]) |
| 272 | + # settings = dict(context_settings=[context]) |
| 273 | + # widget = self.create_widget(OWSelectRows, settings) |
| 274 | + # self.assertEqual(widget.conditions, []) |
264 | 275 |
|
265 | | - ch = SelectRowsContextHandler() |
266 | | - context = ch.new_context(iris.domain, *ch.encode_domain(iris.domain)) |
267 | | - context.values = dict(conditions=[["petal length", 2, (5.2,)]]) |
268 | | - settings = dict(context_settings=[context]) |
269 | | - widget = self.create_widget(OWSelectRows, settings) |
270 | | - self.assertEqual(widget.conditions, []) |
| 276 | + @override_locale(QLocale.C) |
| 277 | + def test_use_settings(self): |
| 278 | + iris = Table("iris") |
| 279 | + self.widget = self.widget_with_context( |
| 280 | + iris.domain, [["sepal length", 2, ("5.2",)]]) |
| 281 | + self.send_signal(self.widget.Inputs.data, iris) |
| 282 | + condition = self.widget.conditions[0] |
| 283 | + self.assertEqual(condition[0], "sepal length") |
| 284 | + self.assertEqual(condition[1], 2) |
| 285 | + self.assertTrue(condition[2][0].startswith("5.2")) |
| 286 | + |
| 287 | + def test_end_support_for_version_0(self): |
| 288 | + if time.gmtime().tm_year == 2021: |
| 289 | + self.fail(""" |
| 290 | +Happy new year 2021! |
| 291 | +
|
| 292 | +Now remove support for version==None settings in |
| 293 | +SelectRowsContextHandler.decode_setting and SelectRowsContextHandler.match, |
| 294 | +uncomment OWSelectRows.migrate, and remove this test. |
| 295 | +
|
| 296 | +Basically, undo this commit. |
| 297 | +""") |
271 | 298 |
|
272 | 299 | def widget_with_context(self, domain, conditions): |
273 | 300 | ch = SelectRowsContextHandler() |
|
0 commit comments