code: def test_context_sharing():
      """Test context sharing"""
      with Canvas() as c1:
          vert = "attribute vec4 pos;\nvoid main (void) {gl_Position = pos;}"
          frag = "void main (void) {gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);}"
          program = Program(vert, frag)
          program["pos"] = [(1, 2, 3, 1), (4, 5, 6, 1)]
          program.draw("points")
  
          def check():
              # Do something to program and see if it worked
              program["pos"] = [
                  (1, 2, 3, 1),
                  (4, 5, 6, 1),
              ]  # Do command
              program.draw("points")
              check_error()
  
          # Check while c1 is active
          check()
  
          # pyqt5 does not currently support context sharing, pyside6 seg faults on app tests
          if (
              "pyqt5" in c1.app.backend_name.lower()
              or "pyqt6" in c1.app.backend_name.lower()
              or "pyside2" in c1.app.backend_name.lower()
              or "pyside6" in c1.app.backend_name.lower()
          ):
              pytest.xfail(
                  "Context sharing is not supported in PyQt5, PyQt6, PySide2, or PySide6 at this time."
              )
  
          # Tkinter does not currently support context sharing
          if "tk" in c1.app.backend_name.lower():
              pytest.xfail(
                  "Context sharing is not supported in Tkinter at this time."
              )
  
          # Check while c2 is active (with different context)
          with Canvas() as c2:
              # pyglet always shares
              if "pyglet" not in c2.app.backend_name.lower():
                  assert_raises(Exception, check)
  
          # Check while c2 is active (with *same* context)
          with Canvas(shared=c1.context) as c2:
              assert (
                  c1.context.shared is c2.context.shared
              )  # same object
              check()
  
file_path: vispy/vispy/app/tests/test_context.py
imports: import sys
  import pytest
  from vispy.testing import requires_application, SkipTest, run_tests_if_main, assert_raises, IS_CI
  from vispy.app import Canvas, use_app
  from vispy.gloo import get_gl_configuration, Program
  from vispy.gloo.gl import check_error
label_desc: Use image node_id 2 for calling a global function with example usage: test_context_sharing() without return types