code: def test_keychoice():
      c = ct.EnsureKeyChoice(
          key="some", values=("choice1", "choice2", None)
      )
      assert_equal(c({"some": "choice1"}), {"some": "choice1"})
      assert_equal(c({"some": None}), {"some": None})
      assert_equal(
          c({"some": None, "ign": "ore"}), {"some": None, "ign": "ore"}
      )
      assert_raises(ValueError, c, "fail")
      assert_raises(ValueError, c, "None")
      assert_raises(ValueError, c, {"nope": "None"})
      assert_raises(ValueError, c, {"some": "None"})
      assert_raises(ValueError, c, {"some": ("a", "b")})
  
file_path: datalad/datalad/tests/test_constraints.py
imports: from datalad.tests.utils_pytest import assert_equal, assert_raises
  from ..support import constraints
label_desc: Use image node_id 9 for calling a global function with example usage: test_keychoice() without return types