Remove `skip-string-normalization` in Python formatter config
[babeltrace.git] / tests / bindings / python / bt2 / test_value.py
index d0e5c38a714304d0e253558d5fe20cd0578b3fb9..62b09888d796043c75f887f2a3aac772f799a72b 100644 (file)
@@ -1,12 +1,20 @@
+# SPDX-License-Identifier: GPL-2.0-only
+#
+# Copyright (C) 2019 EfficiOS Inc.
+#
+
 from functools import partial, partialmethod
 import operator
+import collections
 import unittest
-import numbers
 import math
 import copy
 import bt2
 
 
+# The value object classes explicitly do not implement the copy methods,
+# raising `NotImplementedError`, just in case we decide to implement
+# them someday.
 class _TestCopySimple:
     def test_copy(self):
         with self.assertRaises(NotImplementedError):
@@ -17,62 +25,93 @@ class _TestCopySimple:
             copy.deepcopy(self._def)
 
 
-_COMP_BINOPS = (
-    operator.eq,
-    operator.ne,
-)
+_COMP_BINOPS = (operator.eq, operator.ne)
 
 
+# Base class for numeric value test cases.
+#
+# To be compatible with this base class, a derived class must, in its
+# setUp() method:
+#
+# * Set `self._def` to a value object with an arbitrary raw value.
+# * Set `self._def_value` to the equivalent raw value of `self._def`.
 class _TestNumericValue(_TestCopySimple):
+    # Tries the binary operation `op`:
+    #
+    # 1. Between `self._def`, which is a value object, and `rhs`.
+    # 2. Between `self._def_value`, which is the raw value of
+    #    `self._def`, and `rhs`.
+    #
+    # Returns the results of 1. and 2.
+    #
+    # If there's an exception while performing 1. or 2., asserts that
+    # both operations raised exceptions, that both exceptions have the
+    # same type, and returns `None` for both results.
     def _binop(self, op, rhs):
-        rexc = None
-        rvexc = None
+        type_rexc = None
+        type_rvexc = None
         comp_value = rhs
 
+        # try with value object
         try:
             r = op(self._def, rhs)
         except Exception as e:
-            rexc = e
+            type_rexc = type(e)
 
+        # try with raw value
         try:
             rv = op(self._def_value, comp_value)
         except Exception as e:
-            rvexc = e
+            type_rvexc = type(e)
 
-        if rexc is not None or rvexc is not None:
+        if type_rexc is not None or type_rvexc is not None:
             # at least one of the operations raised an exception: in
             # this case both operations should have raised the same
             # type of exception (division by zero, bit shift with a
             # floating point number operand, etc.)
-            self.assertIs(type(rexc), type(rvexc))
+            self.assertIs(type_rexc, type_rvexc)
             return None, None
 
         return r, rv
 
+    # Tries the unary operation `op`:
+    #
+    # 1. On `self._def`, which is a value object.
+    # 2. On `self._def_value`, which is the raw value of `self._def`.
+    #
+    # Returns the results of 1. and 2.
+    #
+    # If there's an exception while performing 1. or 2., asserts that
+    # both operations raised exceptions, that both exceptions have the
+    # same type, and returns `None` for both results.
     def _unaryop(self, op):
-        rexc = None
-        rvexc = None
+        type_rexc = None
+        type_rvexc = None
 
+        # try with value object
         try:
             r = op(self._def)
         except Exception as e:
-            rexc = e
+            type_rexc = type(e)
 
+        # try with raw value
         try:
             rv = op(self._def_value)
         except Exception as e:
-            rvexc = e
+            type_rvexc = type(e)
 
-        if rexc is not None or rvexc is not None:
+        if type_rexc is not None or type_rvexc is not None:
             # at least one of the operations raised an exception: in
             # this case both operations should have raised the same
             # type of exception (division by zero, bit shift with a
             # floating point number operand, etc.)
-            self.assertIs(type(rexc), type(rvexc))
+            self.assertIs(type_rexc, type_rvexc)
             return None, None
 
         return r, rv
 
+    # Tests that the unary operation `op` gives results with the same
+    # type for both `self._def` and `self._def_value`.
     def _test_unaryop_type(self, op):
         r, rv = self._unaryop(op)
 
@@ -81,6 +120,9 @@ class _TestNumericValue(_TestCopySimple):
 
         self.assertIsInstance(r, type(rv))
 
+    # Tests that the unary operation `op` gives results with the same
+    # value for both `self._def` and `self._def_value`. This uses the
+    # __eq__() operator of `self._def`.
     def _test_unaryop_value(self, op):
         r, rv = self._unaryop(op)
 
@@ -89,16 +131,22 @@ class _TestNumericValue(_TestCopySimple):
 
         self.assertEqual(r, rv)
 
+    # Tests that the unary operation `op`, when applied to `self._def`,
+    # does not change its underlying BT object address.
     def _test_unaryop_addr_same(self, op):
         addr_before = self._def.addr
         self._unaryop(op)
         self.assertEqual(self._def.addr, addr_before)
 
+    # Tests that the unary operation `op`, when applied to `self._def`,
+    # does not change its value.
     def _test_unaryop_value_same(self, op):
         value_before = self._def.__class__(self._def)
         self._unaryop(op)
         self.assertEqual(self._def, value_before)
 
+    # Tests that the binary operation `op` gives results with the same
+    # type for both `self._def` and `self._def_value`.
     def _test_binop_type(self, op, rhs):
         r, rv = self._binop(op, rhs)
 
@@ -111,6 +159,9 @@ class _TestNumericValue(_TestCopySimple):
         else:
             self.assertIsInstance(r, type(rv))
 
+    # Tests that the binary operation `op` gives results with the same
+    # value for both `self._def` and `self._def_value`. This uses the
+    # __eq__() operator of `self._def`.
     def _test_binop_value(self, op, rhs):
         r, rv = self._binop(op, rhs)
 
@@ -119,80 +170,52 @@ class _TestNumericValue(_TestCopySimple):
 
         self.assertEqual(r, rv)
 
+    # Tests that the binary operation `op`, when applied to `self._def`,
+    # does not change its underlying BT object address.
     def _test_binop_lhs_addr_same(self, op, rhs):
         addr_before = self._def.addr
         r, rv = self._binop(op, rhs)
         self.assertEqual(self._def.addr, addr_before)
 
+    # Tests that the binary operation `op`, when applied to `self._def`,
+    # does not change its value.
     def _test_binop_lhs_value_same(self, op, rhs):
         value_before = self._def.__class__(self._def)
         r, rv = self._binop(op, rhs)
         self.assertEqual(self._def, value_before)
 
-    def _test_binop_invalid_unknown(self, op):
-        if op in _COMP_BINOPS:
-            self.skipTest('not testing')
-
-        class A:
-            pass
-
-        with self.assertRaises(TypeError):
-            op(self._def, A())
-
-    def _test_binop_invalid_none(self, op):
-        if op in _COMP_BINOPS:
-            self.skipTest('not testing')
-
-        with self.assertRaises(TypeError):
-            op(self._def, None)
-
-    def _test_ibinop_value(self, op, rhs):
-        r, rv = self._binop(op, rhs)
-
-        if r is None:
-            return
-
-        # The inplace operators are special for value objects because
-        # they do not return a new, immutable object like it's the case
-        # for Python numbers. In Python, `a += 2`, where `a` is a number
-        # object, assigns a new number object reference to `a`, dropping
-        # the old reference. Since BT's value objects are mutable, we
-        # modify their internal value with the inplace operators. This
-        # means however that we can lose data in the process, for
-        # example:
-        #
-        #     int_value_obj += 3.3
-        #
-        # Here, if `int_value_obj` is a Python `int` with the value 2,
-        # it would be a `float` object after this, holding the value
-        # 5.3. In our case, if `int_value_obj` is an integer value
-        # object, 3.3 is converted to an `int` object (3) and added to
-        # the current value of `int_value_obj`, so after this the value
-        # of the object is 5. This does not compare to 5.3, which is
-        # why we also use the `int()` type here.
-        if isinstance(self._def, bt2._IntegerValue):
-            rv = int(rv)
-
-        self.assertEqual(r, rv)
-
-    def _test_ibinop_type(self, op, rhs):
-        r, rv = self._binop(op, rhs)
-
-        if r is None:
-            return
-
-        self.assertIs(r, self._def)
-
-    def _test_ibinop_invalid_unknown(self, op):
-        class A:
-            pass
-
-        with self.assertRaises(TypeError):
-            op(self._def, A())
-
-    def _test_ibinop_invalid_none(self, op):
-        with self.assertRaises(TypeError):
-            op(self._def, None)
+    # The methods below which take the `test_cb` and `op` parameters
+    # are meant to be used with one of the _test_binop_*() functions
+    # above as `test_cb` and a binary operator function as `op`.
+    #
+    # For example:
+    #
+    #     self._test_binop_rhs_pos_int(self._test_binop_value,
+    #                                  operator.add)
+    #
+    # This tests that a numeric value object added to a positive integer
+    # raw value gives a result with the expected value.
+    #
+    # `vint` and `vfloat` mean a signed integer value object and a real
+    # value object.
+
+    def _test_binop_unknown(self, op):
+        if op is operator.eq:
+            self.assertIs(op(self._def, object()), False)
+        elif op is operator.ne:
+            self.assertIs(op(self._def, object()), True)
+        else:
+            with self.assertRaises(TypeError):
+                op(self._def, object())
+
+    def _test_binop_none(self, op):
+        if op is operator.eq:
+            self.assertIs(op(self._def, None), False)
+        elif op is operator.ne:
+            self.assertIs(op(self._def, None), True)
+        else:
+            with self.assertRaises(TypeError):
+                op(self._def, None)
 
     def _test_binop_rhs_false(self, test_cb, op):
         test_cb(op, False)
@@ -227,6 +250,12 @@ class _TestNumericValue(_TestCopySimple):
     def _test_binop_rhs_zero_float(self, test_cb, op):
         test_cb(op, 0.0)
 
+    def _test_binop_rhs_complex(self, test_cb, op):
+        test_cb(op, -23 + 19j)
+
+    def _test_binop_rhs_zero_complex(self, test_cb, op):
+        test_cb(op, 0j)
+
     def _test_binop_rhs_pos_vfloat(self, test_cb, op):
         test_cb(op, bt2.create_value(2.2))
 
@@ -278,6 +307,12 @@ class _TestNumericValue(_TestCopySimple):
     def _test_binop_type_zero_vfloat(self, op):
         self._test_binop_rhs_zero_vfloat(self._test_binop_type, op)
 
+    def _test_binop_type_complex(self, op):
+        self._test_binop_rhs_complex(self._test_binop_type, op)
+
+    def _test_binop_type_zero_complex(self, op):
+        self._test_binop_rhs_zero_complex(self._test_binop_type, op)
+
     def _test_binop_value_false(self, op):
         self._test_binop_rhs_false(self._test_binop_value, op)
 
@@ -320,6 +355,12 @@ class _TestNumericValue(_TestCopySimple):
     def _test_binop_value_zero_vfloat(self, op):
         self._test_binop_rhs_zero_vfloat(self._test_binop_value, op)
 
+    def _test_binop_value_complex(self, op):
+        self._test_binop_rhs_complex(self._test_binop_value, op)
+
+    def _test_binop_value_zero_complex(self, op):
+        self._test_binop_rhs_zero_complex(self._test_binop_value, op)
+
     def _test_binop_lhs_addr_same_false(self, op):
         self._test_binop_rhs_false(self._test_binop_lhs_addr_same, op)
 
@@ -362,6 +403,12 @@ class _TestNumericValue(_TestCopySimple):
     def _test_binop_lhs_addr_same_zero_vfloat(self, op):
         self._test_binop_rhs_zero_vfloat(self._test_binop_lhs_addr_same, op)
 
+    def _test_binop_lhs_addr_same_complex(self, op):
+        self._test_binop_rhs_complex(self._test_binop_lhs_addr_same, op)
+
+    def _test_binop_lhs_addr_same_zero_complex(self, op):
+        self._test_binop_rhs_zero_complex(self._test_binop_lhs_addr_same, op)
+
     def _test_binop_lhs_value_same_false(self, op):
         self._test_binop_rhs_false(self._test_binop_lhs_value_same, op)
 
@@ -404,89 +451,11 @@ class _TestNumericValue(_TestCopySimple):
     def _test_binop_lhs_value_same_zero_vfloat(self, op):
         self._test_binop_rhs_zero_vfloat(self._test_binop_lhs_value_same, op)
 
-    def _test_ibinop_type_false(self, op):
-        self._test_binop_rhs_false(self._test_ibinop_type, op)
-
-    def _test_ibinop_type_true(self, op):
-        self._test_binop_rhs_true(self._test_ibinop_type, op)
-
-    def _test_ibinop_type_pos_int(self, op):
-        self._test_binop_rhs_pos_int(self._test_ibinop_type, op)
-
-    def _test_ibinop_type_neg_int(self, op):
-        self._test_binop_rhs_neg_int(self._test_ibinop_type, op)
-
-    def _test_ibinop_type_zero_int(self, op):
-        self._test_binop_rhs_zero_int(self._test_ibinop_type, op)
-
-    def _test_ibinop_type_pos_vint(self, op):
-        self._test_binop_rhs_pos_vint(self._test_ibinop_type, op)
-
-    def _test_ibinop_type_neg_vint(self, op):
-        self._test_binop_rhs_neg_vint(self._test_ibinop_type, op)
-
-    def _test_ibinop_type_zero_vint(self, op):
-        self._test_binop_rhs_zero_vint(self._test_ibinop_type, op)
-
-    def _test_ibinop_type_pos_float(self, op):
-        self._test_binop_rhs_pos_float(self._test_ibinop_type, op)
-
-    def _test_ibinop_type_neg_float(self, op):
-        self._test_binop_rhs_neg_float(self._test_ibinop_type, op)
-
-    def _test_ibinop_type_zero_float(self, op):
-        self._test_binop_rhs_zero_float(self._test_ibinop_type, op)
-
-    def _test_ibinop_type_pos_vfloat(self, op):
-        self._test_binop_rhs_pos_vfloat(self._test_ibinop_type, op)
+    def _test_binop_lhs_value_same_complex(self, op):
+        self._test_binop_rhs_complex(self._test_binop_lhs_value_same, op)
 
-    def _test_ibinop_type_neg_vfloat(self, op):
-        self._test_binop_rhs_neg_vfloat(self._test_ibinop_type, op)
-
-    def _test_ibinop_type_zero_vfloat(self, op):
-        self._test_binop_rhs_zero_vfloat(self._test_ibinop_type, op)
-
-    def _test_ibinop_value_false(self, op):
-        self._test_binop_rhs_false(self._test_ibinop_value, op)
-
-    def _test_ibinop_value_true(self, op):
-        self._test_binop_rhs_true(self._test_ibinop_value, op)
-
-    def _test_ibinop_value_pos_int(self, op):
-        self._test_binop_rhs_pos_int(self._test_ibinop_value, op)
-
-    def _test_ibinop_value_neg_int(self, op):
-        self._test_binop_rhs_neg_int(self._test_ibinop_value, op)
-
-    def _test_ibinop_value_zero_int(self, op):
-        self._test_binop_rhs_zero_int(self._test_ibinop_value, op)
-
-    def _test_ibinop_value_pos_vint(self, op):
-        self._test_binop_rhs_pos_vint(self._test_ibinop_value, op)
-
-    def _test_ibinop_value_neg_vint(self, op):
-        self._test_binop_rhs_neg_vint(self._test_ibinop_value, op)
-
-    def _test_ibinop_value_zero_vint(self, op):
-        self._test_binop_rhs_zero_vint(self._test_ibinop_value, op)
-
-    def _test_ibinop_value_pos_float(self, op):
-        self._test_binop_rhs_pos_float(self._test_ibinop_value, op)
-
-    def _test_ibinop_value_neg_float(self, op):
-        self._test_binop_rhs_neg_float(self._test_ibinop_value, op)
-
-    def _test_ibinop_value_zero_float(self, op):
-        self._test_binop_rhs_zero_float(self._test_ibinop_value, op)
-
-    def _test_ibinop_value_pos_vfloat(self, op):
-        self._test_binop_rhs_pos_vfloat(self._test_ibinop_value, op)
-
-    def _test_ibinop_value_neg_vfloat(self, op):
-        self._test_binop_rhs_neg_vfloat(self._test_ibinop_value, op)
-
-    def _test_ibinop_value_zero_vfloat(self, op):
-        self._test_binop_rhs_zero_vfloat(self._test_ibinop_value, op)
+    def _test_binop_lhs_value_same_zero_complex(self, op):
+        self._test_binop_rhs_zero_complex(self._test_binop_lhs_value_same, op)
 
     def test_bool_op(self):
         self.assertEqual(bool(self._def), bool(self._def_value))
@@ -504,200 +473,508 @@ class _TestNumericValue(_TestCopySimple):
         self.assertEqual(str(self._def), str(self._def_value))
 
     def test_eq_none(self):
-        self.assertFalse(self._def == None)
+        # Disable the "comparison to None" warning, as this is precisely what
+        # we want to test here.
+        self.assertFalse(self._def == None)  # noqa: E711
 
     def test_ne_none(self):
-        self.assertTrue(self._def != None)
+        # Disable the "comparison to None" warning, as this is precisely what
+        # we want to test here.
+        self.assertTrue(self._def != None)  # noqa: E711
 
 
+# This is a list of binary operators used for
+# _inject_numeric_testing_methods().
+#
+# Each entry is a pair of binary operator name (used as part of the
+# created testing method's name) and operator function.
 _BINOPS = (
-    ('lt', operator.lt),
-    ('le', operator.le),
-    ('eq', operator.eq),
-    ('ne', operator.ne),
-    ('ge', operator.ge),
-    ('gt', operator.gt),
-    ('add', operator.add),
-    ('radd', lambda a, b: operator.add(b, a)),
-    ('and', operator.and_),
-    ('rand', lambda a, b: operator.and_(b, a)),
-    ('floordiv', operator.floordiv),
-    ('rfloordiv', lambda a, b: operator.floordiv(b, a)),
-    ('lshift', operator.lshift),
-    ('rlshift', lambda a, b: operator.lshift(b, a)),
-    ('mod', operator.mod),
-    ('rmod', lambda a, b: operator.mod(b, a)),
-    ('mul', operator.mul),
-    ('rmul', lambda a, b: operator.mul(b, a)),
-    ('or', operator.or_),
-    ('ror', lambda a, b: operator.or_(b, a)),
-    ('pow', operator.pow),
-    ('rpow', lambda a, b: operator.pow(b, a)),
-    ('rshift', operator.rshift),
-    ('rrshift', lambda a, b: operator.rshift(b, a)),
-    ('sub', operator.sub),
-    ('rsub', lambda a, b: operator.sub(b, a)),
-    ('truediv', operator.truediv),
-    ('rtruediv', lambda a, b: operator.truediv(b, a)),
-    ('xor', operator.xor),
-    ('rxor', lambda a, b: operator.xor(b, a)),
-)
-
-
-_IBINOPS = (
-    ('iadd', operator.iadd),
-    ('iand', operator.iand),
-    ('ifloordiv', operator.ifloordiv),
-    ('ilshift', operator.ilshift),
-    ('imod', operator.imod),
-    ('imul', operator.imul),
-    ('ior', operator.ior),
-    ('ipow', operator.ipow),
-    ('irshift', operator.irshift),
-    ('isub', operator.isub),
-    ('itruediv', operator.itruediv),
-    ('ixor', operator.ixor),
+    ("lt", operator.lt),
+    ("le", operator.le),
+    ("eq", operator.eq),
+    ("ne", operator.ne),
+    ("ge", operator.ge),
+    ("gt", operator.gt),
+    ("add", operator.add),
+    ("radd", lambda a, b: operator.add(b, a)),
+    ("and", operator.and_),
+    ("rand", lambda a, b: operator.and_(b, a)),
+    ("floordiv", operator.floordiv),
+    ("rfloordiv", lambda a, b: operator.floordiv(b, a)),
+    ("lshift", operator.lshift),
+    ("rlshift", lambda a, b: operator.lshift(b, a)),
+    ("mod", operator.mod),
+    ("rmod", lambda a, b: operator.mod(b, a)),
+    ("mul", operator.mul),
+    ("rmul", lambda a, b: operator.mul(b, a)),
+    ("or", operator.or_),
+    ("ror", lambda a, b: operator.or_(b, a)),
+    ("pow", operator.pow),
+    ("rpow", lambda a, b: operator.pow(b, a)),
+    ("rshift", operator.rshift),
+    ("rrshift", lambda a, b: operator.rshift(b, a)),
+    ("sub", operator.sub),
+    ("rsub", lambda a, b: operator.sub(b, a)),
+    ("truediv", operator.truediv),
+    ("rtruediv", lambda a, b: operator.truediv(b, a)),
+    ("xor", operator.xor),
+    ("rxor", lambda a, b: operator.xor(b, a)),
 )
 
 
+# This is a list of unary operators used for
+# _inject_numeric_testing_methods().
+#
+# Each entry is a pair of unary operator name (used as part of the
+# created testing method's name) and operator function.
 _UNARYOPS = (
-    ('neg', operator.neg),
-    ('pos', operator.pos),
-    ('abs', operator.abs),
-    ('invert', operator.invert),
-    ('round', round),
-    ('round_0', partial(round, ndigits=0)),
-    ('round_1', partial(round, ndigits=1)),
-    ('round_2', partial(round, ndigits=2)),
-    ('round_3', partial(round, ndigits=3)),
-    ('ceil', math.ceil),
-    ('floor', math.floor),
-    ('trunc', math.trunc),
+    ("neg", operator.neg),
+    ("pos", operator.pos),
+    ("abs", operator.abs),
+    ("invert", operator.invert),
+    ("round", round),
+    ("round_0", partial(round, ndigits=0)),
+    ("round_1", partial(round, ndigits=1)),
+    ("round_2", partial(round, ndigits=2)),
+    ("round_3", partial(round, ndigits=3)),
+    ("ceil", math.ceil),
+    ("floor", math.floor),
+    ("trunc", math.trunc),
 )
 
 
-def _inject_numeric_testing_methods(cls, has_neg=True):
+# This function injects a bunch of testing methods to a numeric
+# value test case.
+#
+# It is meant to be used like this:
+#
+#     _inject_numeric_testing_methods(MyNumericValueTestCase)
+#
+# This function injects:
+#
+# * One testing method for each _TestNumericValue._test_binop_*()
+#   method, for each binary operator in the _BINOPS tuple.
+#
+# * One testing method for each _TestNumericValue._test_unaryop*()
+#   method, for each unary operator in the _UNARYOPS tuple.
+def _inject_numeric_testing_methods(cls):
     def test_binop_name(suffix):
-        return 'test_binop_{}_{}'.format(name, suffix)
-
-    def test_ibinop_name(suffix):
-        return 'test_ibinop_{}_{}'.format(name, suffix)
+        return "test_binop_{}_{}".format(name, suffix)
 
     def test_unaryop_name(suffix):
-        return 'test_unaryop_{}_{}'.format(name, suffix)
+        return "test_unaryop_{}_{}".format(name, suffix)
 
     # inject testing methods for each binary operation
     for name, binop in _BINOPS:
-        setattr(cls, test_binop_name('invalid_unknown'), partialmethod(_TestNumericValue._test_binop_invalid_unknown, op=binop))
-        setattr(cls, test_binop_name('invalid_none'), partialmethod(_TestNumericValue._test_binop_invalid_none, op=binop))
-        setattr(cls, test_binop_name('type_true'), partialmethod(_TestNumericValue._test_binop_type_true, op=binop))
-        setattr(cls, test_binop_name('type_pos_int'), partialmethod(_TestNumericValue._test_binop_type_pos_int, op=binop))
-        setattr(cls, test_binop_name('type_pos_vint'), partialmethod(_TestNumericValue._test_binop_type_pos_vint, op=binop))
-        setattr(cls, test_binop_name('value_true'), partialmethod(_TestNumericValue._test_binop_value_true, op=binop))
-        setattr(cls, test_binop_name('value_pos_int'), partialmethod(_TestNumericValue._test_binop_value_pos_int, op=binop))
-        setattr(cls, test_binop_name('value_pos_vint'), partialmethod(_TestNumericValue._test_binop_value_pos_vint, op=binop))
-        setattr(cls, test_binop_name('lhs_addr_same_true'), partialmethod(_TestNumericValue._test_binop_lhs_addr_same_true, op=binop))
-        setattr(cls, test_binop_name('lhs_addr_same_pos_int'), partialmethod(_TestNumericValue._test_binop_lhs_addr_same_pos_int, op=binop))
-        setattr(cls, test_binop_name('lhs_addr_same_pos_vint'), partialmethod(_TestNumericValue._test_binop_lhs_addr_same_pos_vint, op=binop))
-        setattr(cls, test_binop_name('lhs_value_same_true'), partialmethod(_TestNumericValue._test_binop_lhs_value_same_true, op=binop))
-        setattr(cls, test_binop_name('lhs_value_same_pos_int'), partialmethod(_TestNumericValue._test_binop_lhs_value_same_pos_int, op=binop))
-        setattr(cls, test_binop_name('lhs_value_same_pos_vint'), partialmethod(_TestNumericValue._test_binop_lhs_value_same_pos_vint, op=binop))
-
-        if has_neg:
-            setattr(cls, test_binop_name('type_neg_int'), partialmethod(_TestNumericValue._test_binop_type_neg_int, op=binop))
-            setattr(cls, test_binop_name('type_neg_vint'), partialmethod(_TestNumericValue._test_binop_type_neg_vint, op=binop))
-            setattr(cls, test_binop_name('value_neg_int'), partialmethod(_TestNumericValue._test_binop_value_neg_int, op=binop))
-            setattr(cls, test_binop_name('value_neg_vint'), partialmethod(_TestNumericValue._test_binop_value_neg_vint, op=binop))
-            setattr(cls, test_binop_name('lhs_addr_same_neg_int'), partialmethod(_TestNumericValue._test_binop_lhs_addr_same_neg_int, op=binop))
-            setattr(cls, test_binop_name('lhs_addr_same_neg_vint'), partialmethod(_TestNumericValue._test_binop_lhs_addr_same_neg_vint, op=binop))
-            setattr(cls, test_binop_name('lhs_value_same_neg_int'), partialmethod(_TestNumericValue._test_binop_lhs_value_same_neg_int, op=binop))
-            setattr(cls, test_binop_name('lhs_value_same_neg_vint'), partialmethod(_TestNumericValue._test_binop_lhs_value_same_neg_vint, op=binop))
-
-        setattr(cls, test_binop_name('type_false'), partialmethod(_TestNumericValue._test_binop_type_false, op=binop))
-        setattr(cls, test_binop_name('type_zero_int'), partialmethod(_TestNumericValue._test_binop_type_zero_int, op=binop))
-        setattr(cls, test_binop_name('type_zero_vint'), partialmethod(_TestNumericValue._test_binop_type_zero_vint, op=binop))
-        setattr(cls, test_binop_name('value_false'), partialmethod(_TestNumericValue._test_binop_value_false, op=binop))
-        setattr(cls, test_binop_name('value_zero_int'), partialmethod(_TestNumericValue._test_binop_value_zero_int, op=binop))
-        setattr(cls, test_binop_name('value_zero_vint'), partialmethod(_TestNumericValue._test_binop_value_zero_vint, op=binop))
-        setattr(cls, test_binop_name('lhs_addr_same_false'), partialmethod(_TestNumericValue._test_binop_lhs_addr_same_false, op=binop))
-        setattr(cls, test_binop_name('lhs_addr_same_zero_int'), partialmethod(_TestNumericValue._test_binop_lhs_addr_same_zero_int, op=binop))
-        setattr(cls, test_binop_name('lhs_addr_same_zero_vint'), partialmethod(_TestNumericValue._test_binop_lhs_addr_same_zero_vint, op=binop))
-        setattr(cls, test_binop_name('lhs_value_same_false'), partialmethod(_TestNumericValue._test_binop_lhs_value_same_false, op=binop))
-        setattr(cls, test_binop_name('lhs_value_same_zero_int'), partialmethod(_TestNumericValue._test_binop_lhs_value_same_zero_int, op=binop))
-        setattr(cls, test_binop_name('lhs_value_same_zero_vint'), partialmethod(_TestNumericValue._test_binop_lhs_value_same_zero_vint, op=binop))
-
-        if has_neg:
-            setattr(cls, test_binop_name('type_neg_float'), partialmethod(_TestNumericValue._test_binop_type_neg_float, op=binop))
-            setattr(cls, test_binop_name('type_neg_vfloat'), partialmethod(_TestNumericValue._test_binop_type_neg_vfloat, op=binop))
-            setattr(cls, test_binop_name('value_neg_float'), partialmethod(_TestNumericValue._test_binop_value_neg_float, op=binop))
-            setattr(cls, test_binop_name('value_neg_vfloat'), partialmethod(_TestNumericValue._test_binop_value_neg_vfloat, op=binop))
-            setattr(cls, test_binop_name('lhs_addr_same_neg_float'), partialmethod(_TestNumericValue._test_binop_lhs_addr_same_neg_float, op=binop))
-            setattr(cls, test_binop_name('lhs_addr_same_neg_vfloat'), partialmethod(_TestNumericValue._test_binop_lhs_addr_same_neg_vfloat, op=binop))
-            setattr(cls, test_binop_name('lhs_value_same_neg_float'), partialmethod(_TestNumericValue._test_binop_lhs_value_same_neg_float, op=binop))
-            setattr(cls, test_binop_name('lhs_value_same_neg_vfloat'), partialmethod(_TestNumericValue._test_binop_lhs_value_same_neg_vfloat, op=binop))
-
-        setattr(cls, test_binop_name('type_pos_float'), partialmethod(_TestNumericValue._test_binop_type_pos_float, op=binop))
-        setattr(cls, test_binop_name('type_pos_vfloat'), partialmethod(_TestNumericValue._test_binop_type_pos_vfloat, op=binop))
-        setattr(cls, test_binop_name('value_pos_float'), partialmethod(_TestNumericValue._test_binop_value_pos_float, op=binop))
-        setattr(cls, test_binop_name('value_pos_vfloat'), partialmethod(_TestNumericValue._test_binop_value_pos_vfloat, op=binop))
-        setattr(cls, test_binop_name('lhs_addr_same_pos_float'), partialmethod(_TestNumericValue._test_binop_lhs_addr_same_pos_float, op=binop))
-        setattr(cls, test_binop_name('lhs_addr_same_pos_vfloat'), partialmethod(_TestNumericValue._test_binop_lhs_addr_same_pos_vfloat, op=binop))
-        setattr(cls, test_binop_name('lhs_value_same_pos_float'), partialmethod(_TestNumericValue._test_binop_lhs_value_same_pos_float, op=binop))
-        setattr(cls, test_binop_name('lhs_value_same_pos_vfloat'), partialmethod(_TestNumericValue._test_binop_lhs_value_same_pos_vfloat, op=binop))
-        setattr(cls, test_binop_name('type_zero_float'), partialmethod(_TestNumericValue._test_binop_type_zero_float, op=binop))
-        setattr(cls, test_binop_name('type_zero_vfloat'), partialmethod(_TestNumericValue._test_binop_type_zero_vfloat, op=binop))
-        setattr(cls, test_binop_name('value_zero_float'), partialmethod(_TestNumericValue._test_binop_value_zero_float, op=binop))
-        setattr(cls, test_binop_name('value_zero_vfloat'), partialmethod(_TestNumericValue._test_binop_value_zero_vfloat, op=binop))
-        setattr(cls, test_binop_name('lhs_addr_same_zero_float'), partialmethod(_TestNumericValue._test_binop_lhs_addr_same_zero_float, op=binop))
-        setattr(cls, test_binop_name('lhs_addr_same_zero_vfloat'), partialmethod(_TestNumericValue._test_binop_lhs_addr_same_zero_vfloat, op=binop))
-        setattr(cls, test_binop_name('lhs_value_same_zero_float'), partialmethod(_TestNumericValue._test_binop_lhs_value_same_zero_float, op=binop))
-        setattr(cls, test_binop_name('lhs_value_same_zero_vfloat'), partialmethod(_TestNumericValue._test_binop_lhs_value_same_zero_vfloat, op=binop))
+        setattr(
+            cls,
+            test_binop_name("unknown"),
+            partialmethod(_TestNumericValue._test_binop_unknown, op=binop),
+        )
+        setattr(
+            cls,
+            test_binop_name("none"),
+            partialmethod(_TestNumericValue._test_binop_none, op=binop),
+        )
+        setattr(
+            cls,
+            test_binop_name("type_true"),
+            partialmethod(_TestNumericValue._test_binop_type_true, op=binop),
+        )
+        setattr(
+            cls,
+            test_binop_name("type_pos_int"),
+            partialmethod(_TestNumericValue._test_binop_type_pos_int, op=binop),
+        )
+        setattr(
+            cls,
+            test_binop_name("type_pos_vint"),
+            partialmethod(_TestNumericValue._test_binop_type_pos_vint, op=binop),
+        )
+        setattr(
+            cls,
+            test_binop_name("value_true"),
+            partialmethod(_TestNumericValue._test_binop_value_true, op=binop),
+        )
+        setattr(
+            cls,
+            test_binop_name("value_pos_int"),
+            partialmethod(_TestNumericValue._test_binop_value_pos_int, op=binop),
+        )
+        setattr(
+            cls,
+            test_binop_name("value_pos_vint"),
+            partialmethod(_TestNumericValue._test_binop_value_pos_vint, op=binop),
+        )
+        setattr(
+            cls,
+            test_binop_name("lhs_addr_same_true"),
+            partialmethod(_TestNumericValue._test_binop_lhs_addr_same_true, op=binop),
+        )
+        setattr(
+            cls,
+            test_binop_name("lhs_addr_same_pos_int"),
+            partialmethod(
+                _TestNumericValue._test_binop_lhs_addr_same_pos_int, op=binop
+            ),
+        )
+        setattr(
+            cls,
+            test_binop_name("lhs_addr_same_pos_vint"),
+            partialmethod(
+                _TestNumericValue._test_binop_lhs_addr_same_pos_vint, op=binop
+            ),
+        )
+        setattr(
+            cls,
+            test_binop_name("lhs_value_same_true"),
+            partialmethod(_TestNumericValue._test_binop_lhs_value_same_true, op=binop),
+        )
+        setattr(
+            cls,
+            test_binop_name("lhs_value_same_pos_int"),
+            partialmethod(
+                _TestNumericValue._test_binop_lhs_value_same_pos_int, op=binop
+            ),
+        )
+        setattr(
+            cls,
+            test_binop_name("lhs_value_same_pos_vint"),
+            partialmethod(
+                _TestNumericValue._test_binop_lhs_value_same_pos_vint, op=binop
+            ),
+        )
+        setattr(
+            cls,
+            test_binop_name("type_neg_int"),
+            partialmethod(_TestNumericValue._test_binop_type_neg_int, op=binop),
+        )
+        setattr(
+            cls,
+            test_binop_name("type_neg_vint"),
+            partialmethod(_TestNumericValue._test_binop_type_neg_vint, op=binop),
+        )
+        setattr(
+            cls,
+            test_binop_name("value_neg_int"),
+            partialmethod(_TestNumericValue._test_binop_value_neg_int, op=binop),
+        )
+        setattr(
+            cls,
+            test_binop_name("value_neg_vint"),
+            partialmethod(_TestNumericValue._test_binop_value_neg_vint, op=binop),
+        )
+        setattr(
+            cls,
+            test_binop_name("lhs_addr_same_neg_int"),
+            partialmethod(
+                _TestNumericValue._test_binop_lhs_addr_same_neg_int, op=binop
+            ),
+        )
+        setattr(
+            cls,
+            test_binop_name("lhs_addr_same_neg_vint"),
+            partialmethod(
+                _TestNumericValue._test_binop_lhs_addr_same_neg_vint, op=binop
+            ),
+        )
+        setattr(
+            cls,
+            test_binop_name("lhs_value_same_neg_int"),
+            partialmethod(
+                _TestNumericValue._test_binop_lhs_value_same_neg_int, op=binop
+            ),
+        )
+        setattr(
+            cls,
+            test_binop_name("lhs_value_same_neg_vint"),
+            partialmethod(
+                _TestNumericValue._test_binop_lhs_value_same_neg_vint, op=binop
+            ),
+        )
+        setattr(
+            cls,
+            test_binop_name("type_false"),
+            partialmethod(_TestNumericValue._test_binop_type_false, op=binop),
+        )
+        setattr(
+            cls,
+            test_binop_name("type_zero_int"),
+            partialmethod(_TestNumericValue._test_binop_type_zero_int, op=binop),
+        )
+        setattr(
+            cls,
+            test_binop_name("type_zero_vint"),
+            partialmethod(_TestNumericValue._test_binop_type_zero_vint, op=binop),
+        )
+        setattr(
+            cls,
+            test_binop_name("value_false"),
+            partialmethod(_TestNumericValue._test_binop_value_false, op=binop),
+        )
+        setattr(
+            cls,
+            test_binop_name("value_zero_int"),
+            partialmethod(_TestNumericValue._test_binop_value_zero_int, op=binop),
+        )
+        setattr(
+            cls,
+            test_binop_name("value_zero_vint"),
+            partialmethod(_TestNumericValue._test_binop_value_zero_vint, op=binop),
+        )
+        setattr(
+            cls,
+            test_binop_name("lhs_addr_same_false"),
+            partialmethod(_TestNumericValue._test_binop_lhs_addr_same_false, op=binop),
+        )
+        setattr(
+            cls,
+            test_binop_name("lhs_addr_same_zero_int"),
+            partialmethod(
+                _TestNumericValue._test_binop_lhs_addr_same_zero_int, op=binop
+            ),
+        )
+        setattr(
+            cls,
+            test_binop_name("lhs_addr_same_zero_vint"),
+            partialmethod(
+                _TestNumericValue._test_binop_lhs_addr_same_zero_vint, op=binop
+            ),
+        )
+        setattr(
+            cls,
+            test_binop_name("lhs_value_same_false"),
+            partialmethod(_TestNumericValue._test_binop_lhs_value_same_false, op=binop),
+        )
+        setattr(
+            cls,
+            test_binop_name("lhs_value_same_zero_int"),
+            partialmethod(
+                _TestNumericValue._test_binop_lhs_value_same_zero_int, op=binop
+            ),
+        )
+        setattr(
+            cls,
+            test_binop_name("lhs_value_same_zero_vint"),
+            partialmethod(
+                _TestNumericValue._test_binop_lhs_value_same_zero_vint, op=binop
+            ),
+        )
+        setattr(
+            cls,
+            test_binop_name("type_neg_float"),
+            partialmethod(_TestNumericValue._test_binop_type_neg_float, op=binop),
+        )
+        setattr(
+            cls,
+            test_binop_name("type_neg_vfloat"),
+            partialmethod(_TestNumericValue._test_binop_type_neg_vfloat, op=binop),
+        )
+        setattr(
+            cls,
+            test_binop_name("value_neg_float"),
+            partialmethod(_TestNumericValue._test_binop_value_neg_float, op=binop),
+        )
+        setattr(
+            cls,
+            test_binop_name("value_neg_vfloat"),
+            partialmethod(_TestNumericValue._test_binop_value_neg_vfloat, op=binop),
+        )
+        setattr(
+            cls,
+            test_binop_name("lhs_addr_same_neg_float"),
+            partialmethod(
+                _TestNumericValue._test_binop_lhs_addr_same_neg_float, op=binop
+            ),
+        )
+        setattr(
+            cls,
+            test_binop_name("lhs_addr_same_neg_vfloat"),
+            partialmethod(
+                _TestNumericValue._test_binop_lhs_addr_same_neg_vfloat, op=binop
+            ),
+        )
+        setattr(
+            cls,
+            test_binop_name("lhs_value_same_neg_float"),
+            partialmethod(
+                _TestNumericValue._test_binop_lhs_value_same_neg_float, op=binop
+            ),
+        )
+        setattr(
+            cls,
+            test_binop_name("lhs_value_same_neg_vfloat"),
+            partialmethod(
+                _TestNumericValue._test_binop_lhs_value_same_neg_vfloat, op=binop
+            ),
+        )
+        setattr(
+            cls,
+            test_binop_name("type_pos_float"),
+            partialmethod(_TestNumericValue._test_binop_type_pos_float, op=binop),
+        )
+        setattr(
+            cls,
+            test_binop_name("type_pos_vfloat"),
+            partialmethod(_TestNumericValue._test_binop_type_pos_vfloat, op=binop),
+        )
+        setattr(
+            cls,
+            test_binop_name("value_pos_float"),
+            partialmethod(_TestNumericValue._test_binop_value_pos_float, op=binop),
+        )
+        setattr(
+            cls,
+            test_binop_name("value_pos_vfloat"),
+            partialmethod(_TestNumericValue._test_binop_value_pos_vfloat, op=binop),
+        )
+        setattr(
+            cls,
+            test_binop_name("lhs_addr_same_pos_float"),
+            partialmethod(
+                _TestNumericValue._test_binop_lhs_addr_same_pos_float, op=binop
+            ),
+        )
+        setattr(
+            cls,
+            test_binop_name("lhs_addr_same_pos_vfloat"),
+            partialmethod(
+                _TestNumericValue._test_binop_lhs_addr_same_pos_vfloat, op=binop
+            ),
+        )
+        setattr(
+            cls,
+            test_binop_name("lhs_value_same_pos_float"),
+            partialmethod(
+                _TestNumericValue._test_binop_lhs_value_same_pos_float, op=binop
+            ),
+        )
+        setattr(
+            cls,
+            test_binop_name("lhs_value_same_pos_vfloat"),
+            partialmethod(
+                _TestNumericValue._test_binop_lhs_value_same_pos_vfloat, op=binop
+            ),
+        )
+        setattr(
+            cls,
+            test_binop_name("type_zero_float"),
+            partialmethod(_TestNumericValue._test_binop_type_zero_float, op=binop),
+        )
+        setattr(
+            cls,
+            test_binop_name("type_zero_vfloat"),
+            partialmethod(_TestNumericValue._test_binop_type_zero_vfloat, op=binop),
+        )
+        setattr(
+            cls,
+            test_binop_name("value_zero_float"),
+            partialmethod(_TestNumericValue._test_binop_value_zero_float, op=binop),
+        )
+        setattr(
+            cls,
+            test_binop_name("value_zero_vfloat"),
+            partialmethod(_TestNumericValue._test_binop_value_zero_vfloat, op=binop),
+        )
+        setattr(
+            cls,
+            test_binop_name("lhs_addr_same_zero_float"),
+            partialmethod(
+                _TestNumericValue._test_binop_lhs_addr_same_zero_float, op=binop
+            ),
+        )
+        setattr(
+            cls,
+            test_binop_name("lhs_addr_same_zero_vfloat"),
+            partialmethod(
+                _TestNumericValue._test_binop_lhs_addr_same_zero_vfloat, op=binop
+            ),
+        )
+        setattr(
+            cls,
+            test_binop_name("lhs_value_same_zero_float"),
+            partialmethod(
+                _TestNumericValue._test_binop_lhs_value_same_zero_float, op=binop
+            ),
+        )
+        setattr(
+            cls,
+            test_binop_name("lhs_value_same_zero_vfloat"),
+            partialmethod(
+                _TestNumericValue._test_binop_lhs_value_same_zero_vfloat, op=binop
+            ),
+        )
+        setattr(
+            cls,
+            test_binop_name("type_complex"),
+            partialmethod(_TestNumericValue._test_binop_type_complex, op=binop),
+        )
+        setattr(
+            cls,
+            test_binop_name("type_zero_complex"),
+            partialmethod(_TestNumericValue._test_binop_type_zero_complex, op=binop),
+        )
+        setattr(
+            cls,
+            test_binop_name("value_complex"),
+            partialmethod(_TestNumericValue._test_binop_value_complex, op=binop),
+        )
+        setattr(
+            cls,
+            test_binop_name("value_zero_complex"),
+            partialmethod(_TestNumericValue._test_binop_value_zero_complex, op=binop),
+        )
+        setattr(
+            cls,
+            test_binop_name("lhs_addr_same_complex"),
+            partialmethod(
+                _TestNumericValue._test_binop_lhs_addr_same_complex, op=binop
+            ),
+        )
+        setattr(
+            cls,
+            test_binop_name("lhs_addr_same_zero_complex"),
+            partialmethod(
+                _TestNumericValue._test_binop_lhs_addr_same_zero_complex, op=binop
+            ),
+        )
+        setattr(
+            cls,
+            test_binop_name("lhs_value_same_complex"),
+            partialmethod(
+                _TestNumericValue._test_binop_lhs_value_same_complex, op=binop
+            ),
+        )
+        setattr(
+            cls,
+            test_binop_name("lhs_value_same_zero_complex"),
+            partialmethod(
+                _TestNumericValue._test_binop_lhs_value_same_zero_complex, op=binop
+            ),
+        )
 
     # inject testing methods for each unary operation
     for name, unaryop in _UNARYOPS:
-        setattr(cls, test_unaryop_name('type'), partialmethod(_TestNumericValue._test_unaryop_type, op=unaryop))
-        setattr(cls, test_unaryop_name('value'), partialmethod(_TestNumericValue._test_unaryop_value, op=unaryop))
-        setattr(cls, test_unaryop_name('addr_same'), partialmethod(_TestNumericValue._test_unaryop_addr_same, op=unaryop))
-        setattr(cls, test_unaryop_name('value_same'), partialmethod(_TestNumericValue._test_unaryop_value_same, op=unaryop))
-
-    # inject testing methods for each inplace binary operation
-    for name, ibinop in _IBINOPS:
-        setattr(cls, test_ibinop_name('invalid_unknown'), partialmethod(_TestNumericValue._test_ibinop_invalid_unknown, op=ibinop))
-        setattr(cls, test_ibinop_name('invalid_none'), partialmethod(_TestNumericValue._test_ibinop_invalid_none, op=ibinop))
-        setattr(cls, test_ibinop_name('type_true'), partialmethod(_TestNumericValue._test_ibinop_type_true, op=ibinop))
-        setattr(cls, test_ibinop_name('value_true'), partialmethod(_TestNumericValue._test_ibinop_value_true, op=ibinop))
-        setattr(cls, test_ibinop_name('type_pos_int'), partialmethod(_TestNumericValue._test_ibinop_type_pos_int, op=ibinop))
-        setattr(cls, test_ibinop_name('type_pos_vint'), partialmethod(_TestNumericValue._test_ibinop_type_pos_vint, op=ibinop))
-        setattr(cls, test_ibinop_name('value_pos_int'), partialmethod(_TestNumericValue._test_ibinop_value_pos_int, op=ibinop))
-        setattr(cls, test_ibinop_name('value_pos_vint'), partialmethod(_TestNumericValue._test_ibinop_value_pos_vint, op=ibinop))
-
-        if has_neg:
-            setattr(cls, test_ibinop_name('type_neg_int'), partialmethod(_TestNumericValue._test_ibinop_type_neg_int, op=ibinop))
-            setattr(cls, test_ibinop_name('type_neg_vint'), partialmethod(_TestNumericValue._test_ibinop_type_neg_vint, op=ibinop))
-            setattr(cls, test_ibinop_name('value_neg_int'), partialmethod(_TestNumericValue._test_ibinop_value_neg_int, op=ibinop))
-            setattr(cls, test_ibinop_name('value_neg_vint'), partialmethod(_TestNumericValue._test_ibinop_value_neg_vint, op=ibinop))
-
-        setattr(cls, test_ibinop_name('type_false'), partialmethod(_TestNumericValue._test_ibinop_type_false, op=ibinop))
-        setattr(cls, test_ibinop_name('value_false'), partialmethod(_TestNumericValue._test_ibinop_value_false, op=ibinop))
-        setattr(cls, test_ibinop_name('type_zero_int'), partialmethod(_TestNumericValue._test_ibinop_type_zero_int, op=ibinop))
-        setattr(cls, test_ibinop_name('type_zero_vint'), partialmethod(_TestNumericValue._test_ibinop_type_zero_vint, op=ibinop))
-        setattr(cls, test_ibinop_name('value_zero_int'), partialmethod(_TestNumericValue._test_ibinop_value_zero_int, op=ibinop))
-        setattr(cls, test_ibinop_name('value_zero_vint'), partialmethod(_TestNumericValue._test_ibinop_value_zero_vint, op=ibinop))
-        setattr(cls, test_ibinop_name('type_pos_float'), partialmethod(_TestNumericValue._test_ibinop_type_pos_float, op=ibinop))
-
-        if has_neg:
-            setattr(cls, test_ibinop_name('type_neg_float'), partialmethod(_TestNumericValue._test_ibinop_type_neg_float, op=ibinop))
-            setattr(cls, test_ibinop_name('type_neg_vfloat'), partialmethod(_TestNumericValue._test_ibinop_type_neg_vfloat, op=ibinop))
-            setattr(cls, test_ibinop_name('value_neg_float'), partialmethod(_TestNumericValue._test_ibinop_value_neg_float, op=ibinop))
-            setattr(cls, test_ibinop_name('value_neg_vfloat'), partialmethod(_TestNumericValue._test_ibinop_value_neg_vfloat, op=ibinop))
-
-        setattr(cls, test_ibinop_name('type_pos_vfloat'), partialmethod(_TestNumericValue._test_ibinop_type_pos_vfloat, op=ibinop))
-        setattr(cls, test_ibinop_name('value_pos_float'), partialmethod(_TestNumericValue._test_ibinop_value_pos_float, op=ibinop))
-        setattr(cls, test_ibinop_name('value_pos_vfloat'), partialmethod(_TestNumericValue._test_ibinop_value_pos_vfloat, op=ibinop))
-        setattr(cls, test_ibinop_name('type_zero_float'), partialmethod(_TestNumericValue._test_ibinop_type_zero_float, op=ibinop))
-        setattr(cls, test_ibinop_name('type_zero_vfloat'), partialmethod(_TestNumericValue._test_ibinop_type_zero_vfloat, op=ibinop))
-        setattr(cls, test_ibinop_name('value_zero_float'), partialmethod(_TestNumericValue._test_ibinop_value_zero_float, op=ibinop))
-        setattr(cls, test_ibinop_name('value_zero_vfloat'), partialmethod(_TestNumericValue._test_ibinop_value_zero_vfloat, op=ibinop))
+        setattr(
+            cls,
+            test_unaryop_name("type"),
+            partialmethod(_TestNumericValue._test_unaryop_type, op=unaryop),
+        )
+        setattr(
+            cls,
+            test_unaryop_name("value"),
+            partialmethod(_TestNumericValue._test_unaryop_value, op=unaryop),
+        )
+        setattr(
+            cls,
+            test_unaryop_name("addr_same"),
+            partialmethod(_TestNumericValue._test_unaryop_addr_same, op=unaryop),
+        )
+        setattr(
+            cls,
+            test_unaryop_name("value_same"),
+            partialmethod(_TestNumericValue._test_unaryop_value_same, op=unaryop),
+        )
 
 
 class CreateValueFuncTestCase(unittest.TestCase):
@@ -740,13 +1017,13 @@ class CreateValueFuncTestCase(unittest.TestCase):
         self.assertEqual(v, raw)
 
     def test_create_string(self):
-        raw = 'salut'
+        raw = "salut"
         v = bt2.create_value(raw)
         self.assertIsInstance(v, bt2.StringValue)
         self.assertEqual(v, raw)
 
     def test_create_string_empty(self):
-        raw = ''
+        raw = ""
         v = bt2.create_value(raw)
         self.assertIsInstance(v, bt2.StringValue)
         self.assertEqual(v, raw)
@@ -776,7 +1053,7 @@ class CreateValueFuncTestCase(unittest.TestCase):
         self.assertEqual(v, raw)
 
     def test_create_map(self):
-        raw = {'salut': 23}
+        raw = {"salut": 23}
         v = bt2.create_value(raw)
         self.assertIsInstance(v, bt2.MapValue)
         self.assertEqual(v, raw)
@@ -798,11 +1075,27 @@ class CreateValueFuncTestCase(unittest.TestCase):
 
         a = A()
 
-        with self.assertRaisesRegex(TypeError, "cannot create value object from 'A' object") as cm:
-            v = bt2.create_value(a)
+        with self.assertRaisesRegex(
+            TypeError, "cannot create value object from 'A' object"
+        ):
+            bt2.create_value(a)
+
+
+def _create_const_value(value):
+    class MySink(bt2._UserSinkComponent):
+        def _user_consume(self):
+            pass
 
+        @classmethod
+        def _user_query(cls, priv_query_exec, obj, params, method_obj):
+            nonlocal value
+            return {"my_value": value}
 
-class BoolValueTestCase(_TestCopySimple, unittest.TestCase):
+    res = bt2.QueryExecutor(MySink, "obj", None).query()
+    return res["my_value"]
+
+
+class BoolValueTestCase(_TestNumericValue, unittest.TestCase):
     def setUp(self):
         self._f = bt2.BoolValue(False)
         self._t = bt2.BoolValue(True)
@@ -838,11 +1131,11 @@ class BoolValueTestCase(_TestCopySimple, unittest.TestCase):
 
     def test_create_from_int_non_zero(self):
         with self.assertRaises(TypeError):
-            b = bt2.BoolValue(23)
+            bt2.BoolValue(23)
 
     def test_create_from_int_zero(self):
         with self.assertRaises(TypeError):
-            b = bt2.BoolValue(0)
+            bt2.BoolValue(0)
 
     def test_assign_true(self):
         b = bt2.BoolValue()
@@ -876,10 +1169,14 @@ class BoolValueTestCase(_TestCopySimple, unittest.TestCase):
         self.assertEqual(str(self._def), str(self._def_value))
 
     def test_eq_none(self):
-        self.assertFalse(self._def == None)
+        # Disable the "comparison to None" warning, as this is precisely what
+        # we want to test here.
+        self.assertFalse(self._def == None)  # noqa: E711
 
     def test_ne_none(self):
-        self.assertTrue(self._def != None)
+        # Disable the "comparison to None" warning, as this is precisely what
+        # we want to test here.
+        self.assertTrue(self._def != None)  # noqa: E711
 
     def test_vfalse_eq_false(self):
         self.assertEqual(self._f, False)
@@ -894,6 +1191,9 @@ class BoolValueTestCase(_TestCopySimple, unittest.TestCase):
         self.assertNotEqual(self._t, False)
 
 
+_inject_numeric_testing_methods(BoolValueTestCase)
+
+
 class _TestIntegerValue(_TestNumericValue):
     def setUp(self):
         self._pv = 23
@@ -908,13 +1208,17 @@ class _TestIntegerValue(_TestNumericValue):
         del self._def_value
 
     def _assert_expecting_int(self):
-        return self.assertRaisesRegex(TypeError, r'expecting a number object')
+        return self.assertRaisesRegex(TypeError, r"expecting an integral number object")
 
     def _assert_expecting_int64(self):
-        return self.assertRaisesRegex(ValueError, r"expecting a signed 64-bit integral value")
+        return self.assertRaisesRegex(
+            ValueError, r"expecting a signed 64-bit integral value"
+        )
 
     def _assert_expecting_uint64(self):
-        return self.assertRaisesRegex(ValueError, r"expecting an unsigned 64-bit integral value")
+        return self.assertRaisesRegex(
+            ValueError, r"expecting an unsigned 64-bit integral value"
+        )
 
     def test_create_default(self):
         i = self._CLS()
@@ -938,25 +1242,16 @@ class _TestIntegerValue(_TestNumericValue):
         i = self._CLS(True)
         self.assertTrue(i)
 
-    def test_create_from_float(self):
-        i = self._CLS(99.6)
-        self.assertEqual(i, 99)
-
-    def test_create_from_vfloat(self):
-        f = bt2.create_value(17.5)
-        i = self._CLS(f)
-        self.assertEqual(i, 17)
-
     def test_create_from_unknown(self):
         class A:
             pass
 
         with self._assert_expecting_int():
-            i = self._CLS(A())
+            self._CLS(A())
 
     def test_create_from_varray(self):
         with self._assert_expecting_int():
-            i = self._CLS(bt2.ArrayValue())
+            self._CLS(bt2.ArrayValue())
 
     def test_assign_true(self):
         raw = True
@@ -978,11 +1273,6 @@ class _TestIntegerValue(_TestNumericValue):
         self._def.value = bt2.create_value(raw)
         self.assertEqual(self._def, raw)
 
-    def test_assign_vfloat(self):
-        raw = 123.456
-        self._def.value = bt2.create_value(raw)
-        self.assertEqual(self._def, int(raw))
-
 
 class SignedIntegerValueTestCase(_TestIntegerValue, unittest.TestCase):
     _CLS = bt2.SignedIntegerValue
@@ -1002,17 +1292,24 @@ class SignedIntegerValueTestCase(_TestIntegerValue, unittest.TestCase):
 
     def test_create_pos_too_big(self):
         with self._assert_expecting_int64():
-            i = self._CLS(2 ** 63)
+            self._CLS(2**63)
 
     def test_create_neg_too_big(self):
         with self._assert_expecting_int64():
-            i = self._CLS(-(2 ** 63) - 1)
+            self._CLS(-(2**63) - 1)
 
     def test_assign_neg_int(self):
         raw = -13
         self._def.value = raw
         self.assertEqual(self._def, raw)
 
+    def test_compare_big_int(self):
+        # Larger than the IEEE 754 double-precision exact representation of
+        # integers.
+        raw = (2**53) + 1
+        v = bt2.create_value(raw)
+        self.assertEqual(v, raw)
+
 
 _inject_numeric_testing_methods(SignedIntegerValueTestCase)
 
@@ -1022,14 +1319,14 @@ class UnsignedIntegerValueTestCase(_TestIntegerValue, unittest.TestCase):
 
     def test_create_pos_too_big(self):
         with self._assert_expecting_uint64():
-            i = self._CLS(2 ** 64)
+            self._CLS(2**64)
 
     def test_create_neg(self):
         with self._assert_expecting_uint64():
-            i = self._CLS(-1)
+            self._CLS(-1)
 
 
-_inject_numeric_testing_methods(UnsignedIntegerValueTestCase, False)
+_inject_numeric_testing_methods(UnsignedIntegerValueTestCase)
 
 
 class RealValueTestCase(_TestNumericValue, unittest.TestCase):
@@ -1065,10 +1362,6 @@ class RealValueTestCase(_TestNumericValue, unittest.TestCase):
     def test_create_neg(self):
         self.assertEqual(self._fn, self._nv)
 
-    def test_create_from_vint(self):
-        f = bt2.RealValue(self._fp)
-        self.assertEqual(f, self._pv)
-
     def test_create_from_false(self):
         f = bt2.RealValue(False)
         self.assertFalse(f)
@@ -1097,11 +1390,11 @@ class RealValueTestCase(_TestNumericValue, unittest.TestCase):
             pass
 
         with self._assert_expecting_float():
-            f = bt2.RealValue(A())
+            bt2.RealValue(A())
 
     def test_create_from_varray(self):
         with self._assert_expecting_float():
-            f = bt2.RealValue(bt2.ArrayValue())
+            bt2.RealValue(bt2.ArrayValue())
 
     def test_assign_true(self):
         self._def.value = True
@@ -1160,9 +1453,10 @@ _inject_numeric_testing_methods(RealValueTestCase)
 
 class StringValueTestCase(_TestCopySimple, unittest.TestCase):
     def setUp(self):
-        self._def_value = 'Hello, World!'
+        self._def_value = "Hello, World!"
         self._def = bt2.StringValue(self._def_value)
-        self._def_new_value = 'Yes!'
+        self._def_const = _create_const_value(self._def_value)
+        self._def_new_value = "Yes!"
 
     def tearDown(self):
         del self._def
@@ -1172,15 +1466,15 @@ class StringValueTestCase(_TestCopySimple, unittest.TestCase):
 
     def test_create_default(self):
         s = bt2.StringValue()
-        self.assertEqual(s, '')
+        self.assertEqual(s, "")
 
     def test_create_from_str(self):
-        raw = 'liberté'
+        raw = "liberté"
         s = bt2.StringValue(raw)
         self.assertEqual(s, raw)
 
     def test_create_from_vstr(self):
-        raw = 'liberté'
+        raw = "liberté"
         s = bt2.StringValue(bt2.create_value(raw))
         self.assertEqual(s, raw)
 
@@ -1189,67 +1483,79 @@ class StringValueTestCase(_TestCopySimple, unittest.TestCase):
             pass
 
         with self._assert_expecting_str():
-            i = bt2.StringValue(A())
+            bt2.StringValue(A())
 
     def test_create_from_varray(self):
         with self._assert_expecting_str():
-            i = bt2.StringValue(bt2.ArrayValue())
+            bt2.StringValue(bt2.ArrayValue())
 
     def test_assign_int(self):
         with self._assert_expecting_str():
             self._def.value = 283
 
     def test_assign_str(self):
-        raw = 'zorg'
+        raw = "zorg"
         self._def = raw
         self.assertEqual(self._def, raw)
 
     def test_assign_vstr(self):
-        raw = 'zorg'
+        raw = "zorg"
         self._def = bt2.create_value(raw)
         self.assertEqual(self._def, raw)
 
     def test_eq(self):
         self.assertEqual(self._def, self._def_value)
 
-    def test_eq(self):
+    def test_const_eq(self):
+        self.assertEqual(self._def_const, self._def_value)
+
+    def test_eq_raw(self):
         self.assertNotEqual(self._def, 23)
 
     def test_lt_vstring(self):
-        s1 = bt2.StringValue('allo')
-        s2 = bt2.StringValue('bateau')
+        s1 = bt2.StringValue("allo")
+        s2 = bt2.StringValue("bateau")
         self.assertLess(s1, s2)
 
     def test_lt_string(self):
-        s1 = bt2.StringValue('allo')
-        self.assertLess(s1, 'bateau')
+        s1 = bt2.StringValue("allo")
+        self.assertLess(s1, "bateau")
 
     def test_le_vstring(self):
-        s1 = bt2.StringValue('allo')
-        s2 = bt2.StringValue('bateau')
+        s1 = bt2.StringValue("allo")
+        s2 = bt2.StringValue("bateau")
         self.assertLessEqual(s1, s2)
 
     def test_le_string(self):
-        s1 = bt2.StringValue('allo')
-        self.assertLessEqual(s1, 'bateau')
+        s1 = bt2.StringValue("allo")
+        self.assertLessEqual(s1, "bateau")
 
     def test_gt_vstring(self):
-        s1 = bt2.StringValue('allo')
-        s2 = bt2.StringValue('bateau')
+        s1 = bt2.StringValue("allo")
+        s2 = bt2.StringValue("bateau")
         self.assertGreater(s2, s1)
 
     def test_gt_string(self):
-        s1 = bt2.StringValue('allo')
-        self.assertGreater('bateau', s1)
+        s1 = bt2.StringValue("allo")
+        self.assertGreater("bateau", s1)
 
     def test_ge_vstring(self):
-        s1 = bt2.StringValue('allo')
-        s2 = bt2.StringValue('bateau')
+        s1 = bt2.StringValue("allo")
+        s2 = bt2.StringValue("bateau")
         self.assertGreaterEqual(s2, s1)
 
     def test_ge_string(self):
-        s1 = bt2.StringValue('allo')
-        self.assertGreaterEqual('bateau', s1)
+        s1 = bt2.StringValue("allo")
+        self.assertGreaterEqual("bateau", s1)
+
+    def test_in_string(self):
+        s1 = bt2.StringValue("beau grand bateau")
+        self.assertIn("bateau", s1)
+
+    def test_in_vstring(self):
+        s1 = bt2.StringValue("beau grand bateau")
+        s2 = bt2.StringValue("bateau")
+        self.assertIn(s2, s1)
 
     def test_bool_op(self):
         self.assertEqual(bool(self._def), bool(self._def_value))
@@ -1263,14 +1569,24 @@ class StringValueTestCase(_TestCopySimple, unittest.TestCase):
     def test_getitem(self):
         self.assertEqual(self._def[5], self._def_value[5])
 
-    def test_append_str(self):
-        to_append = 'meow meow meow'
+    def test_const_getitem(self):
+        self.assertEqual(self._def_const[5], self._def_value[5])
+
+    def test_iadd_str(self):
+        to_append = "meow meow meow"
         self._def += to_append
         self._def_value += to_append
         self.assertEqual(self._def, self._def_value)
 
+    def test_const_iadd_str(self):
+        to_append = "meow meow meow"
+        with self.assertRaises(TypeError):
+            self._def_const += to_append
+
+        self.assertEqual(self._def_const, self._def_value)
+
     def test_append_vstr(self):
-        to_append = 'meow meow meow'
+        to_append = "meow meow meow"
         self._def += bt2.create_value(to_append)
         self._def_value += to_append
         self.assertEqual(self._def, self._def_value)
@@ -1278,14 +1594,15 @@ class StringValueTestCase(_TestCopySimple, unittest.TestCase):
 
 class ArrayValueTestCase(_TestCopySimple, unittest.TestCase):
     def setUp(self):
-        self._def_value = [None, False, True, -23, 0, 42, -42.4, 23.17, 'yes']
+        self._def_value = [None, False, True, -23, 0, 42, -42.4, 23.17, "yes"]
         self._def = bt2.ArrayValue(copy.deepcopy(self._def_value))
+        self._def_const = _create_const_value(copy.deepcopy(self._def_value))
 
     def tearDown(self):
         del self._def
 
     def _modify_def(self):
-        self._def[2] = 'xyz'
+        self._def[2] = "xyz"
 
     def _assert_type_error(self):
         return self.assertRaises(TypeError)
@@ -1312,7 +1629,7 @@ class ArrayValueTestCase(_TestCopySimple, unittest.TestCase):
             pass
 
         with self._assert_type_error():
-            a = bt2.ArrayValue(A())
+            bt2.ArrayValue(A())
 
     def test_bool_op_true(self):
         self.assertTrue(bool(self._def))
@@ -1326,9 +1643,16 @@ class ArrayValueTestCase(_TestCopySimple, unittest.TestCase):
     def test_eq_int(self):
         self.assertNotEqual(self._def, 23)
 
+    def test_const_eq(self):
+        a1 = _create_const_value([1, 2, 3])
+        a2 = [1, 2, 3]
+        self.assertEqual(a1, a2)
+
     def test_eq_diff_len(self):
         a1 = bt2.create_value([1, 2, 3])
         a2 = bt2.create_value([1, 2])
+        self.assertIs(type(a1), bt2.ArrayValue)
+        self.assertIs(type(a2), bt2.ArrayValue)
         self.assertNotEqual(a1, a2)
 
     def test_eq_diff_content_same_len(self):
@@ -1337,11 +1661,17 @@ class ArrayValueTestCase(_TestCopySimple, unittest.TestCase):
         self.assertNotEqual(a1, a2)
 
     def test_eq_same_content_same_len(self):
-        raw = (3, True, [1, 2.5, None, {'a': 17.6, 'b': None}])
+        raw = (3, True, [1, 2.5, None, {"a": 17.6, "b": None}])
         a1 = bt2.ArrayValue(raw)
         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
@@ -1358,7 +1688,7 @@ class ArrayValueTestCase(_TestCopySimple, unittest.TestCase):
 
     def test_setitem_index_wrong_type(self):
         with self._assert_type_error():
-            self._def['yes'] = 23
+            self._def["yes"] = 23
 
     def test_setitem_index_neg(self):
         with self.assertRaises(IndexError):
@@ -1368,6 +1698,10 @@ class ArrayValueTestCase(_TestCopySimple, unittest.TestCase):
         with self.assertRaises(IndexError):
             self._def[len(self._def)] = 23
 
+    def test_const_setitem(self):
+        with self.assertRaises(TypeError):
+            self._def_const[2] = 19
+
     def test_append_none(self):
         self._def.append(None)
         self.assertIsNone(self._def[len(self._def) - 1])
@@ -1377,6 +1711,10 @@ class ArrayValueTestCase(_TestCopySimple, unittest.TestCase):
         self._def.append(raw)
         self.assertEqual(self._def[len(self._def) - 1], raw)
 
+    def test_const_append(self):
+        with self.assertRaises(AttributeError):
+            self._def_const.append(12194)
+
     def test_append_vint(self):
         raw = 145
         self._def.append(bt2.create_value(raw))
@@ -1396,6 +1734,10 @@ class ArrayValueTestCase(_TestCopySimple, unittest.TestCase):
         self.assertEqual(self._def[len(self._def) - 2], raw[1])
         self.assertEqual(self._def[len(self._def) - 1], raw[2])
 
+    def test_const_iadd(self):
+        with self.assertRaises(TypeError):
+            self._def_const += 12194
+
     def test_iadd_unknown(self):
         class A:
             pass
@@ -1414,27 +1756,53 @@ class ArrayValueTestCase(_TestCopySimple, unittest.TestCase):
         for velem, elem in zip(self._def, self._def_value):
             self.assertEqual(velem, elem)
 
+    def test_const_iter(self):
+        for velem, elem in zip(self._def_const, self._def_value):
+            self.assertEqual(velem, elem)
+
+    def test_const_get_item(self):
+        item1 = self._def_const[0]
+        item2 = self._def_const[2]
+        item3 = self._def_const[5]
+        item4 = self._def_const[7]
+        item5 = self._def_const[8]
+
+        self.assertEqual(item1, None)
+
+        self.assertIs(type(item2), bt2._BoolValueConst)
+        self.assertEqual(item2, True)
+
+        self.assertIs(type(item3), bt2._SignedIntegerValueConst)
+        self.assertEqual(item3, 42)
+
+        self.assertIs(type(item4), bt2._RealValueConst)
+        self.assertEqual(item4, 23.17)
+
+        self.assertIs(type(item5), bt2._StringValueConst)
+        self.assertEqual(item5, "yes")
+
 
 class MapValueTestCase(_TestCopySimple, unittest.TestCase):
     def setUp(self):
         self._def_value = {
-            'none': None,
-            'false': False,
-            'true': True,
-            'neg-int': -23,
-            'zero': 0,
-            'pos-int': 42,
-            'neg-float': -42.4,
-            'pos-float': 23.17,
-            'str': 'yes'
+            "none": None,
+            "false": False,
+            "true": True,
+            "neg-int": -23,
+            "zero": 0,
+            "pos-int": 42,
+            "neg-float": -42.4,
+            "pos-float": 23.17,
+            "str": "yes",
         }
         self._def = bt2.MapValue(copy.deepcopy(self._def_value))
+        self._def_const = _create_const_value(self._def_value)
 
     def tearDown(self):
         del self._def
 
     def _modify_def(self):
-        self._def['zero'] = 1
+        self._def["zero"] = 1
 
     def test_create_default(self):
         m = bt2.MapValue()
@@ -1453,7 +1821,7 @@ class MapValueTestCase(_TestCopySimple, unittest.TestCase):
             pass
 
         with self.assertRaises(AttributeError):
-            m = bt2.MapValue(A())
+            bt2.MapValue(A())
 
     def test_bool_op_true(self):
         self.assertTrue(bool(self._def))
@@ -1464,53 +1832,80 @@ class MapValueTestCase(_TestCopySimple, unittest.TestCase):
     def test_len(self):
         self.assertEqual(len(self._def), len(self._def_value))
 
+    def test_const_eq(self):
+        a1 = _create_const_value({"a": 1, "b": 2, "c": 3})
+        a2 = {"a": 1, "b": 2, "c": 3}
+        self.assertEqual(a1, a2)
+
     def test_eq_int(self):
         self.assertNotEqual(self._def, 23)
 
     def test_eq_diff_len(self):
-        a1 = bt2.create_value({'a': 1, 'b': 2, 'c': 3})
-        a2 = bt2.create_value({'a': 1, 'b': 2})
+        a1 = bt2.create_value({"a": 1, "b": 2, "c": 3})
+        a2 = bt2.create_value({"a": 1, "b": 2})
+        self.assertNotEqual(a1, a2)
+
+    def test_const_eq_diff_len(self):
+        a1 = _create_const_value({"a": 1, "b": 2, "c": 3})
+        a2 = _create_const_value({"a": 1, "b": 2})
         self.assertNotEqual(a1, a2)
 
     def test_eq_diff_content_same_len(self):
-        a1 = bt2.create_value({'a': 1, 'b': 2, 'c': 3})
-        a2 = bt2.create_value({'a': 4, 'b': 2, 'c': 3})
+        a1 = bt2.create_value({"a": 1, "b": 2, "c": 3})
+        a2 = bt2.create_value({"a": 4, "b": 2, "c": 3})
+        self.assertNotEqual(a1, a2)
+
+    def test_const_eq_diff_content_same_len(self):
+        a1 = _create_const_value({"a": 1, "b": 2, "c": 3})
+        a2 = _create_const_value({"a": 4, "b": 2, "c": 3})
         self.assertNotEqual(a1, a2)
 
     def test_eq_same_content_diff_keys(self):
-        a1 = bt2.create_value({'a': 1, 'b': 2, 'c': 3})
-        a2 = bt2.create_value({'a': 1, 'k': 2, 'c': 3})
+        a1 = bt2.create_value({"a": 1, "b": 2, "c": 3})
+        a2 = bt2.create_value({"a": 1, "k": 2, "c": 3})
+        self.assertNotEqual(a1, a2)
+
+    def test_const_eq_same_content_diff_keys(self):
+        a1 = _create_const_value({"a": 1, "b": 2, "c": 3})
+        a2 = _create_const_value({"a": 1, "k": 2, "c": 3})
         self.assertNotEqual(a1, a2)
 
     def test_eq_same_content_same_len(self):
-        raw = {
-            '3': 3,
-            'True': True,
-            'array': [1, 2.5, None, {'a': 17.6, 'b': None}]
-        }
+        raw = {"3": 3, "True": True, "array": [1, 2.5, None, {"a": 17.6, "b": None}]}
         a1 = bt2.MapValue(raw)
         a2 = bt2.MapValue(copy.deepcopy(raw))
         self.assertEqual(a1, a2)
         self.assertEqual(a1, raw)
 
+    def test_const_eq_same_content_same_len(self):
+        raw = {"3": 3, "True": True, "array": [1, 2.5, None, {"a": 17.6, "b": None}]}
+        a1 = _create_const_value(raw)
+        a2 = _create_const_value(copy.deepcopy(raw))
+        self.assertEqual(a1, a2)
+        self.assertEqual(a1, raw)
+
     def test_setitem_int(self):
         raw = 19
-        self._def['pos-int'] = raw
-        self.assertEqual(self._def['pos-int'], raw)
+        self._def["pos-int"] = raw
+        self.assertEqual(self._def["pos-int"], raw)
+
+    def test_const_setitem_int(self):
+        with self.assertRaises(TypeError):
+            self._def_const["pos-int"] = 19
 
     def test_setitem_vint(self):
         raw = 19
-        self._def['pos-int'] = bt2.create_value(raw)
-        self.assertEqual(self._def['pos-int'], raw)
+        self._def["pos-int"] = bt2.create_value(raw)
+        self.assertEqual(self._def["pos-int"], raw)
 
     def test_setitem_none(self):
-        self._def['none'] = None
-        self.assertIsNone(self._def['none'])
+        self._def["none"] = None
+        self.assertIsNone(self._def["none"])
 
     def test_setitem_new_int(self):
         old_len = len(self._def)
-        self._def['new-int'] = 23
-        self.assertEqual(self._def['new-int'], 23)
+        self._def["new-int"] = 23
+        self.assertEqual(self._def["new-int"], 23)
         self.assertEqual(len(self._def), old_len + 1)
 
     def test_setitem_index_wrong_type(self):
@@ -1522,6 +1917,41 @@ class MapValueTestCase(_TestCopySimple, unittest.TestCase):
             val = self._def_value[vkey]
             self.assertEqual(vval, val)
 
+    def test_const_iter(self):
+        for vkey, vval in self._def_const.items():
+            val = self._def_value[vkey]
+            self.assertEqual(vval, val)
+
+    def test_get_item(self):
+        i = self._def["pos-float"]
+        self.assertIs(type(i), bt2.RealValue)
+        self.assertEqual(i, 23.17)
+
+    def test_const_get_item(self):
+        item1 = self._def_const["none"]
+        item2 = self._def_const["true"]
+        item3 = self._def_const["pos-int"]
+        item4 = self._def_const["pos-float"]
+        item5 = self._def_const["str"]
+
+        self.assertEqual(item1, None)
+
+        self.assertIs(type(item2), bt2._BoolValueConst)
+        self.assertEqual(item2, True)
+
+        self.assertIs(type(item3), bt2._SignedIntegerValueConst)
+        self.assertEqual(item3, 42)
+
+        self.assertIs(type(item4), bt2._RealValueConst)
+        self.assertEqual(item4, 23.17)
+
+        self.assertIs(type(item5), bt2._StringValueConst)
+        self.assertEqual(item5, "yes")
+
     def test_getitem_wrong_key(self):
         with self.assertRaises(KeyError):
-            self._def['kilojoule']
+            self._def["kilojoule"]
+
+
+if __name__ == "__main__":
+    unittest.main()
This page took 0.042229 seconds and 4 git commands to generate.