code: def test_init_allowed_dtype(self):
      # allowed dtypes
      for dtype in (np.uint8, np.uint16, np.uint32):
          b = IndexBuffer(np.zeros(10, dtype=dtype))
          b.dtype == dtype
  
      # no data => no dtype
      V = IndexBuffer()
      V.dtype is None
  
      # Not allowed dtypes
      for dtype in (
          np.int8,
          np.int16,
          np.int32,
          np.float16,
          np.float32,
          np.float64,
      ):
          # with self.assertRaises(TypeError):
          #    V = IndexBuffer(dtype=dtype)
          data = np.zeros(10, dtype=dtype)
          self.assertRaises(TypeError, IndexBuffer, data)
  
      # Prepare some data
      dtype = np.dtype(
          [
              ("position", np.float32, 3),
              ("texcoord", np.float32, 2),
          ]
      )
      sdata = np.zeros(10, dtype=dtype)
  
      # Normal data is
      data = np.zeros([1, 2, 3], np.uint8)
      B = IndexBuffer(data)
      assert B.dtype == np.uint8
  
      # We can also convert
      B.set_data(data, convert=True)
      assert B.dtype == np.uint32
  
      # Structured data not allowed
      self.assertRaises(TypeError, IndexBuffer, dtype=dtype)
      self.assertRaises(TypeError, B.set_data, sdata)
  
imports: import unittest
  import numpy
  from vispy.testing import run_tests_if_main
  from vispy.gloo.buffer import Buffer, DataBuffer, DataBufferView, VertexBuffer, IndexBuffer
label_desc: Use image node_id 1 for calling the IndexBufferTest obj's underlying member method code with example usage: obj.test_init_allowed_dtype() without return types