code: def test_altconstraints():
      # this should always work
      c = ct.AltConstraints(ct.EnsureFloat())
      assert_equal(c(7.0), 7.0)
      c = ct.AltConstraints(ct.EnsureFloat(), ct.EnsureNone())
      assert_equal(c.short_description(), "(float or None)")
      assert_equal(c(7.0), 7.0)
      assert_equal(c(None), None)
      # __or__ form
      c = ct.EnsureFloat() | ct.EnsureNone()
      assert_equal(c(7.0), 7.0)
      assert_equal(c(None), None)
  
      # this should always fail
      c = ct.Constraints(
          ct.EnsureRange(min=0, max=4), ct.EnsureRange(min=9, max=11)
      )
      assert_raises(ValueError, c, 7.0)
      c = ct.EnsureRange(min=0, max=4) | ct.EnsureRange(min=9, max=11)
      assert_equal(c(3.0), 3.0)
      assert_equal(c(9.0), 9.0)
      assert_raises(ValueError, c, 7.0)
      assert_raises(ValueError, c, -1.0)
  
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 14 for calling a global function with example usage: test_altconstraints() without return types