|
1 | 1 | # Test methods with long descriptive names can omit docstrings |
2 | 2 | # pylint: disable=missing-docstring |
3 | 3 | # pylint: disable=protected-access |
4 | | - |
| 4 | +import os |
5 | 5 | import sys |
6 | 6 | import math |
7 | 7 | import unittest |
8 | 8 | import pickle |
9 | 9 | import pkgutil |
| 10 | +import warnings |
10 | 11 | from datetime import datetime, timezone |
11 | 12 |
|
12 | 13 | from io import StringIO |
|
16 | 17 |
|
17 | 18 | import Orange |
18 | 19 | from Orange.data import Variable, ContinuousVariable, DiscreteVariable, \ |
19 | | - StringVariable, TimeVariable, Unknown, Value |
| 20 | + StringVariable, TimeVariable, Unknown, Value, Table |
20 | 21 | from Orange.data.io import CSVReader |
21 | 22 | from Orange.preprocess.transformation import Identity |
22 | 23 | from Orange.tests.base import create_pickling_tests |
@@ -500,6 +501,24 @@ def test_remove_ordered(self): |
500 | 501 | """ |
501 | 502 | self.assertLess(Orange.__version__, "3.29.0") |
502 | 503 |
|
| 504 | + def test_with_older_pickle(self): |
| 505 | + """ |
| 506 | + Test that pickle made with an older version of Orange are correctly |
| 507 | + loaded after changes in DiscreteVariable |
| 508 | + """ |
| 509 | + with warnings.catch_warnings(): |
| 510 | + # travis/gh-action tests change OrangeDeprecationWarning to error |
| 511 | + # temporary disable it |
| 512 | + warnings.simplefilter('default', OrangeDeprecationWarning) |
| 513 | + this_dir = os.path.dirname(os.path.realpath(__file__)) |
| 514 | + datasets_dir = os.path.join( |
| 515 | + this_dir, "..", "..", "tests", "datasets" |
| 516 | + ) |
| 517 | + # pickle with values as list |
| 518 | + Table(os.path.join(datasets_dir, "sailing-orange-3-20.pkl")) |
| 519 | + # pickle with values as tuple list |
| 520 | + Table(os.path.join(datasets_dir, "iris-orange-3-25.pkl")) |
| 521 | + |
503 | 522 |
|
504 | 523 | @variabletest(ContinuousVariable) |
505 | 524 | class TestContinuousVariable(VariableTest): |
|
0 commit comments