code: def test_wrappers():
      """Test gloo wrappers"""
      with Canvas():
          gl.use_gl("gl2 debug")
          gloo.clear(
              "#112233"
          )  # make it so that there's something non-zero
          # check presets
          assert_raises(ValueError, gloo.set_state, preset="foo")
          for state in gloo.get_state_presets().keys():
              gloo.set_state(state)
          assert_raises(
              ValueError, gloo.set_blend_color, (0.0, 0.0)
          )  # bad color
          assert_raises(TypeError, gloo.set_hint, 1, 2)  # need strs
          # this doesn't exist in ES 2.0 namespace
          assert_cmd_raises(
              ValueError, gloo.set_hint, "fog_hint", "nicest"
          )
          # test bad enum
          assert_raises(RuntimeError, gloo.set_line_width, -1)
  
          # check read_pixels
          x = gloo.read_pixels()
          assert_true(isinstance(x, np.ndarray))
          assert_true(
              isinstance(gloo.read_pixels((0, 0, 1, 1)), np.ndarray)
          )
          assert_raises(
              ValueError, gloo.read_pixels, (0, 0, 1)
          )  # bad port
          y = gloo.read_pixels(alpha=False, out_type=np.ubyte)
          assert_equal(y.shape, x.shape[:2] + (3,))
          assert_array_equal(x[..., :3], y)
          y = gloo.read_pixels(out_type="float")
          assert_allclose(x / 255.0, y)
  
          # now let's (indirectly) check our set_* functions
          viewport = (0, 0, 1, 1)
          blend_color = (0.0, 0.0, 0.0)
          _funs = dict(
              viewport=viewport,  # checked
              hint=("generate_mipmap_hint", "nicest"),
              depth_range=(1.0, 2.0),
              front_face="cw",  # checked
              cull_face="front",
              line_width=1.0,
              polygon_offset=(1.0, 1.0),
              blend_func=("zero", "one"),
              blend_color=blend_color,
              blend_equation="func_add",
              scissor=(0, 0, 1, 1),
              stencil_func=("never", 1, 2, "back"),
              stencil_mask=4,
              stencil_op=("zero", "zero", "zero", "back"),
              depth_func="greater",
              depth_mask=True,
              color_mask=(True, True, True, True),
              sample_coverage=(0.5, True),
          )
          gloo.set_state(**_funs)
          gloo.clear((1.0, 1.0, 1.0, 1.0), 0.5, 1)
          gloo.flush()
          gloo.finish()
          # check some results
          assert_array_equal(
              gl.glGetParameter(gl.GL_VIEWPORT), viewport
          )
          assert_equal(gl.glGetParameter(gl.GL_FRONT_FACE), gl.GL_CW)
          assert_equal(
              gl.glGetParameter(gl.GL_BLEND_COLOR), blend_color + (1,)
          )
  
file_path: vispy/vispy/gloo/tests/test_wrappers.py
imports: import numpy
  from numpy.testing import assert_array_equal, assert_allclose
  from vispy import gloo
  from vispy.gloo import gl
  from vispy.app import Canvas
  from vispy.testing import requires_application, run_tests_if_main, assert_true, assert_equal, assert_raises
  from vispy.gloo import read_pixels
  from vispy.gloo.glir import GlirQueue
  from vispy.gloo import wrappers
label_desc: Use image node_id 7 for calling a global function with example usage: test_wrappers() without return types