def test_add_metadata_olive_version_exception(self, mock_getattr, tmp_path):
        """Test handling of exception when getting Olive version."""
        # Setup
        mock_getattr.side_effect = AttributeError("No version attribute")

        input_model = get_onnx_model()
        config = {"graph_name": "exception_test_graph"}
        p = create_pass_from_dict(AddOliveMetadata, config, disable_search=True)
        output_folder = str(tmp_path / "onnx")

        # Execute
        output_model = p.run(input_model, output_folder)

        # Assert
        onnx_model = onnx.load_model(output_model.model_path)
        metadata_dict = {entry.key: entry.value for entry in onnx_model.metadata_props}
        assert metadata_dict["olive_version"] == "unknown"
Test handling of exception when getting Olive version.
test/unit_test/passes/onnx/test_add_metadata.py