code: def test_choice():
      c = ct.EnsureChoice("choice1", "choice2", None)
      # this should always work
      assert_equal(c("choice1"), "choice1")
      assert_equal(c(None), None)
      # this should always fail
      assert_raises(ValueError, lambda: c("fail"))
      assert_raises(ValueError, lambda: c("None"))
  
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 8 for calling a global function with example usage: test_choice() without return types