def test_mutation_fails(self):
        """ Test that any attempt to mutate an immutable typed list fails. """
        self.disable_leak_check()

        def generate_function(line):
            context = {}
            exec(dedent("""
                from numba.typed import listobject
                from numba import int32
                def bar():
                    lst = listobject.new_list(int32)
                    lst.append(int32(1))
                    lst._make_immutable()
                    zero = int32(0)
                    {}
                """.format(line)), context)
            return njit(context["bar"])
        for line in ("lst.append(zero)",
                     "lst[0] = zero",
                     "lst.pop()",
                     "del lst[0]",
                     "lst.extend((zero,))",
                     "lst.insert(0, zero)",
                     "lst.clear()",
                     "lst.reverse()",
                     "lst.sort()",
                     ):
            foo = generate_function(line)
            with self.assertRaises(ValueError) as raises:
                foo()
            self.assertIn(
                "list is immutable",
                str(raises.exception),
            )
 Test that any attempt to mutate an immutable typed list fails. 
numba/tests/test_listobject.py