def test_save_spec_api_mlprogram_without_weights_dir(self):
        """
        save an mlpackage using the save_spec API. It should error out because no weights dir.
        """
        spec = self.mlmodel.get_spec()
        with tempfile.TemporaryDirectory(suffix=utils._MLPACKAGE_EXTENSION) as model_path:
            # this should raise error:
            with pytest.raises(Exception, match="spec of type mlProgram cannot be saved without"
                                                " the weights file. Please provide the path to "
                                                "the weights file as well, using the 'weights_dir' argument."):
                utils.save_spec(spec, model_path)

        save an mlpackage using the save_spec API. It should error out because no weights dir.
        
coremltools/test/modelpackage/test_modelpackage.py