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 List
                def bar():
                    lst = List()
                    lst.append(1)
                    lst._make_immutable()
                    {}
                """.format(line)), context)
            return njit(context["bar"])
        for line in ("lst.append(0)",
                     "lst[0] = 0",
                     "lst.pop()",
                     "del lst[0]",
                     "lst.extend((0,))",
                     "lst.insert(0, 0)",
                     "lst.clear()",
                     "lst.reverse()",
                     "lst.sort()",
                     ):
            foo = generate_function(line)
            for func in (foo, foo.py_func):
                with self.assertRaises(ValueError) as raises:
                    func()
                self.assertIn(
                    "list is immutable",
                    str(raises.exception),
                )
 Test that any attempt to mutate an immutable typed list fails. 
numba/tests/test_typedlist.py