code: def test_draw(self):
      # Init
      program = Program("attribute float A;", "uniform float foo")
      program["A"] = np.zeros((10,), np.float32)
  
      dummy_canvas = DummyCanvas()
      glir = dummy_canvas.context.glir
      set_current_canvas(dummy_canvas)
      try:
          # Draw arrays
          program.draw("triangles")
          glir_cmd = glir.clear()[-1]
          assert glir_cmd[0] == "DRAW"
          assert len(glir_cmd[-2]) == 2
  
          # Draw elements
          indices = gloo.IndexBuffer(np.zeros(10, dtype=np.uint8))
          program.draw("triangles", indices)
          glir_cmd = glir.clear()[-1]
          assert glir_cmd[0] == "DRAW"
          assert len(glir_cmd[-2]) == 3
  
          # Invalid mode
          self.assertRaises(
              ValueError, program.draw, "nogeometricshape"
          )
          # Invalid index
          self.assertRaises(
              TypeError, program.draw, "triangles", "notindex"
          )
          # No atributes
          program = Program("attribute float A;", "uniform float foo")
          self.assertRaises(RuntimeError, program.draw, "triangles")
          # Atributes with different sizes
          program = Program(
              "attribute float A; attribute float B;", "foo"
          )
          program["A"] = np.zeros((10,), np.float32)
          program["B"] = np.zeros((11,), np.float32)
          self.assertRaises(RuntimeError, program.draw, "triangles")
  
      finally:
          forget_canvas(dummy_canvas)
  
imports: import unittest
  import numpy
  from vispy import gloo, app
  from vispy.gloo.program import Program
  from vispy.testing import run_tests_if_main, requires_application
  from vispy.gloo.context import set_current_canvas, forget_canvas
label_desc: Use image node_id 9 for calling the ProgramTest obj's underlying member method code with example usage: obj.test_draw() without return types