class_docstr: Test basic functionality of opset version handling in pymil
class_docstr_tok: ["Test","basic","functionality","of","opset","version","handling","in","pymil"]
docstr: We should error out at the point when Builder tries to add an op which is only supported in a newer spec version
docstr_tok: ["We","should","error","out","at","the","point","when","Builder","tries","to","add","an","op","which","is","only","supported","in","a","newer","spec","version"]
code: def test_unsupported_op_early_error_out():
      """
      We should error out at the point when Builder tries to add an op which is only supported in a newer spec version
      """
      expected_err_str = (
          "No available version for pixel_unshuffle in the coremltools.target.iOS15 opset. "
          "Please update the minimum_deployment_target to at least coremltools.target.iOS16"
      )
      with pytest.raises(ValueError, match=expected_err_str):
  
          @mb.program(
              input_specs=[mb.TensorSpec(shape=(1, 1, 4, 4))],
              opset_version=ct.target.iOS15,
          )
          def prog(x):
              x = mb.pixel_unshuffle(x=x, downscale_factor=np.uint32(2))
              return x
  
imports: import numpy
  import pytest
  import coremltools
  from coremltools import _logger
  from coremltools.converters.mil.mil import Builder
  from coremltools.converters.mil.mil import Function, Program, types
  from coremltools.converters.mil.mil.passes.tests.test_passes import CONSTEXPR_FUNCS
label_desc: Use image node_id 6 for calling the TestMILProgramVersionHandling obj's underlying member method code with example usage: obj.test_unsupported_op_early_error_out() and returns: x