code: def test_str_ucs4(self, s):
      s = np.str_(s)  # only our subclass implements the buffer protocol
  
      # all the same, characters always encode as ucs4
      expected = dict(
          strides=(),
          itemsize=8,
          ndim=0,
          shape=(),
          format="2w",
          readonly=True,
      )
  
      v = memoryview(s)
      assert self._as_dict(v) == expected
  
      # integers of the paltform-appropriate endianness
      code_points = np.frombuffer(v, dtype="i4")
  
      assert_equal(code_points, [ord(c) for c in s])
  
      # Check that we do not allow writeable buffer export
      with pytest.raises(
          BufferError, match="scalar buffer is readonly"
      ):
          get_buffer_info(s, ["WRITABLE"])
  
file_path: numpy/numpy/_core/tests/test_scalarbuffer.py
imports: import numpy
  from numpy._core._rational_tests import rational
  from numpy._core._multiarray_tests import get_buffer_info
  import pytest
  from numpy.testing import assert_, assert_equal, assert_raises
label_desc: Use image node_id 8 for calling the TestScalarPEP3118 obj's underlying member method code with example usage: obj.test_str_ucs4(s) without return types