|
1 | 1 | # Test methods with long descriptive names can omit docstrings |
2 | 2 | # pylint: disable=missing-docstring |
3 | 3 |
|
4 | | -import unittest |
5 | | -from unittest.mock import Mock, patch |
| 4 | +import io |
6 | 5 | import os |
7 | | -import tempfile |
| 6 | +import pickle |
8 | 7 | import shutil |
9 | | -import io |
| 8 | +import tempfile |
| 9 | +import unittest |
| 10 | +from unittest.mock import Mock, patch |
10 | 11 |
|
11 | 12 | from Orange import data |
12 | 13 |
|
13 | 14 | from Orange.data.io import FileFormat, TabReader, CSVReader, PickleReader |
| 15 | +from Orange.data.io_base import PICKLE_PROTOCOL |
14 | 16 | from Orange.data.table import get_sample_datasets_dir |
15 | 17 | from Orange.data import Table, Variable |
16 | 18 | from Orange.tests import test_dirname |
@@ -180,3 +182,17 @@ def test_load_pickle(self): |
180 | 182 | self.assertEqual(attributes_count, len(data2.domain.attributes)) |
181 | 183 | self.assertEqual(attributes_count, len(data3.domain.attributes)) |
182 | 184 | self.assertEqual(attributes_count, len(data4.domain.attributes)) |
| 185 | + |
| 186 | + def test_pickle_version(self): |
| 187 | + """ |
| 188 | + Orange uses a fixed PICKLE_PROTOCOL (currently set to 4) |
| 189 | + for pickling data files and possibly elsewhere for consistent |
| 190 | + behaviour across different python versions (e.g. 3.6 - 3.8). |
| 191 | + When the default protocol is increased in a future version of python |
| 192 | + we should consider increasing this constant to match it as well. |
| 193 | + """ |
| 194 | + # we should use a version that is at least as high as the default. |
| 195 | + # it could be higher for older (but supported) python versions |
| 196 | + self.assertGreaterEqual(PICKLE_PROTOCOL, pickle.DEFAULT_PROTOCOL) |
| 197 | + # we should not use a version that is not supported |
| 198 | + self.assertLessEqual(PICKLE_PROTOCOL, pickle.HIGHEST_PROTOCOL) |
0 commit comments