code: def test_constraints():
      # this should always work
      c = ct.Constraints(ct.EnsureFloat())
      assert_equal(c(7.0), 7.0)
      c = ct.Constraints(ct.EnsureFloat(), ct.EnsureRange(min=4.0))
      assert_equal(c(7.0), 7.0)
      # __and__ form
      c = ct.EnsureFloat() & ct.EnsureRange(min=4.0)
      assert_equal(c(7.0), 7.0)
      assert_raises(ValueError, c, 3.9)
      c = ct.Constraints(
          ct.EnsureFloat(), ct.EnsureRange(min=4), ct.EnsureRange(max=9)
      )
      assert_equal(c(7.0), 7.0)
      assert_raises(ValueError, c, 3.9)
      assert_raises(ValueError, c, 9.01)
      # __and__ form
      c = (
          ct.EnsureFloat()
          & ct.EnsureRange(min=4)
          & ct.EnsureRange(max=9)
      )
      assert_equal(c(7.0), 7.0)
      assert_raises(ValueError, c, 3.99)
      assert_raises(ValueError, c, 9.01)
      # and reordering should not have any effect
      c = ct.Constraints(
          ct.EnsureRange(max=4), ct.EnsureRange(min=9), ct.EnsureFloat()
      )
      assert_raises(ValueError, c, 3.99)
      assert_raises(ValueError, c, 9.01)
  
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 13 for calling a global function with example usage: test_constraints() without return types