code: def test_context_properties():
      """Test setting context properties"""
      a = use_app()
      if a.backend_name.lower() == "pyglet":
          return  # cannot set more than once on Pyglet
      if a.backend_name.lower() == "osmesa":
          return  # cannot set config on OSMesa
      if (
          "pyqt5" in a.backend_name.lower()
          or "pyqt6" in a.backend_name.lower()
          or "pyside2" in a.backend_name.lower()
          or "pyside6" in a.backend_name.lower()
      ):
          pytest.xfail(
              "Context sharing is not supported in PyQt5, PyQt6, PySide2, or PySide6 at this time."
          )
  
      # stereo, double buffer won't work on every sys
      configs = [
          dict(samples=4),
          dict(stencil_size=8),
          dict(samples=4, stencil_size=8),
      ]
      if (
          a.backend_name.lower() != "glfw"
      ):  # glfw *always* double-buffers
          configs.append(dict(double_buffer=False, samples=4))
          configs.append(dict(double_buffer=False))
      else:
          assert_raises(
              RuntimeError,
              Canvas,
              app=a,
              config=dict(double_buffer=False),
          )
      if a.backend_name.lower() == "sdl2" and IS_CI:
          raise SkipTest("Travis SDL cannot set context")
      for config in configs:
          n_items = len(config)
          with Canvas(config=config):
              if IS_CI:
                  # Travis and Appveyor cannot handle obtaining these values
                  props = config
              else:
                  props = get_gl_configuration()
              assert len(config) == n_items
              for key, val in config.items():
                  # XXX knownfail for windows samples, and wx/tkinter (all platforms)
                  if key == "samples":
                      will_fail_backend = a.backend_name.lower() in (
                          "wx",
                          "tkinter",
                      )
                      if not (
                          sys.platform.startswith("win")
                          or will_fail_backend
                      ):
                          assert val == props[key], key
      assert_raises(TypeError, Canvas, config="foo")
      assert_raises(KeyError, Canvas, config=dict(foo=True))
      assert_raises(TypeError, Canvas, config=dict(double_buffer="foo"))
  
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 1 for calling a global function with example usage: test_context_properties() without return types