code: def test_nonwriteable_setfield(self):
      # gh-8171
      r = np.rec.array([(0,), (1,)], dtype=[("f", "i4")])
      r.flags.writeable = False
      with assert_raises(ValueError):
          r.f = [2, 3]
      with assert_raises(ValueError):
          r.setfield([2, 3], *r.dtype.fields["f"])
  
imports: import collections.abc
  import textwrap
  from io import BytesIO
  from os import path
  from pathlib import Path
  import pytest
  import numpy
  from numpy.testing import assert_, assert_equal, assert_array_equal, assert_array_almost_equal, assert_raises, temppath
  from numpy.compat import pickle
label_desc: Use image node_id 5 for calling the TestRecord obj's underlying member method code with example usage: obj.test_nonwriteable_setfield() without return types