The new tests verify that an array field or an array value is not equal
to another iterable object which would provide the correct element
values, but which is not a `collections.abc.Sequence`. This is similar
to how
[1, 3, 5] == collections.OrderedDict([(1, 2), (3, 4), (5, 6)])
is false.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: If7402e4f0e747d2c9d17ddb5ce7aa4fc4156314d
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1588
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
import math
import copy
import itertools
+import collections
import bt2
from utils import get_default_trace_class
field[2] = 1948754
self.assertNotEqual(self._def, field)
+ def test_eq_non_sequence_iterable(self):
+ dct = collections.OrderedDict([(1, 2), (3, 4), (5, 6)])
+ field = _create_int_array_field(self._tc, 3)
+ field[0] = 1
+ field[1] = 3
+ field[2] = 5
+ self.assertEqual(field, list(dct.keys()))
+ self.assertNotEqual(field, dct)
+
def test_setitem(self):
self._def[2] = 24
self.assertEqual(self._def[2], 24)
from functools import partial, partialmethod
import operator
+import collections
import unittest
import numbers
import math
a2 = bt2.ArrayValue(copy.deepcopy(raw))
self.assertEqual(a1, a2)
+ def test_eq_non_sequence_iterable(self):
+ dct = collections.OrderedDict([(1, 2), (3, 4), (5, 6)])
+ a = bt2.ArrayValue((1, 3, 5))
+ self.assertEqual(a, list(dct.keys()))
+ self.assertNotEqual(a, dct)
+
def test_setitem_int(self):
raw = 19
self._def[2] = raw