@@ -27,12 +27,10 @@ function test_errors_fallback_AddVariableNotAllowed()
2727 try
2828 MOI. add_variable (model)
2929 catch err
30- @test sprint (showerror, err) ==
31- " MathOptInterface.AddVariableNotAllowed:" *
32- " Adding variables cannot be performed. You may want to use a" *
33- " `CachingOptimizer` in `AUTOMATIC` mode or you may need to call" *
34- " `reset_optimizer` before doing this operation if the" *
35- " `CachingOptimizer` is in `MANUAL` mode."
30+ contents = sprint (showerror, err)
31+ @test occursin (" $(MOI. AddVariableNotAllowed) " , contents)
32+ @test occursin (" Adding variables cannot be performed" , contents)
33+ @test occursin (" ## Fixing this error" , contents)
3634 end
3735 @test_throws MOI. AddVariableNotAllowed MOI. add_variables (model, 2 )
3836 return
@@ -104,13 +102,14 @@ function test_errors_add_constraint()
104102 try
105103 MOI. add_constraint (model, vi, MOI. EqualTo (0.0 ))
106104 catch err
107- @test sprint (showerror, err) ==
108- " $(MOI. AddConstraintNotAllowed{MOI. VariableIndex,MOI. EqualTo{Float64}}) :" *
109- " Adding `$MOI .VariableIndex`-in-`$MOI .EqualTo{Float64}`" *
110- " constraints cannot be performed. You may want to use a" *
111- " `CachingOptimizer` in `AUTOMATIC` mode or you may need to call" *
112- " `reset_optimizer` before doing this operation if the" *
113- " `CachingOptimizer` is in `MANUAL` mode."
105+ contents = sprint (showerror, err)
106+ F, S = MOI. VariableIndex, MOI. EqualTo{Float64}
107+ @test occursin (" $(MOI. AddConstraintNotAllowed{F,S}) " , contents)
108+ @test occursin (
109+ " Adding `$F `-in-`$S ` constraints cannot be performed" ,
110+ contents,
111+ )
112+ @test occursin (" ## Fixing this error" , contents)
114113 end
115114 @test_throws (
116115 MOI. AddConstraintNotAllowed,
@@ -141,7 +140,7 @@ function test_errors_DeleteNotAllowed()
141140 catch err
142141 contents = sprint (showerror, err)
143142 @test occursin (" $(MOI. DeleteNotAllowed{typeof (vi)}) " , contents)
144- @test occursin (" Deleting the index $vi " , contents)
143+ @test occursin (" Deleting the index $vi cannot be performed " , contents)
145144 @test occursin (" ## Fixing this error" , contents)
146145 end
147146 @test_throws MOI. DeleteNotAllowed{typeof (ci)} MOI. delete (model, ci)
@@ -150,7 +149,7 @@ function test_errors_DeleteNotAllowed()
150149 catch err
151150 contents = sprint (showerror, err)
152151 @test occursin (" $(MOI. DeleteNotAllowed{typeof (ci)}) " , contents)
153- @test occursin (" Deleting the index $ci " , contents)
152+ @test occursin (" Deleting the index $ci cannot be performed " , contents)
154153 @test occursin (" ## Fixing this error" , contents)
155154 end
156155 return
@@ -242,7 +241,10 @@ function test_errors_ModifyNotAllowed_constraint()
242241 @test_throws err MOI. modify (model, ci, change)
243242 contents = sprint (showerror, err)
244243 @test occursin (" $(typeof (err)) :" , contents)
245- @test occursin (" Modifying the constraints $ci " , contents)
244+ @test occursin (
245+ " Modifying the constraints $ci with $change cannot be performed" ,
246+ contents,
247+ )
246248 @test occursin (" ## Fixing this error" , contents)
247249 return
248250end
@@ -255,7 +257,10 @@ function test_errors_ModifyNotAllowed_objective()
255257 @test_throws err MOI. modify (model, attr, change)
256258 contents = sprint (showerror, err)
257259 @test occursin (" $(typeof (err)) :" , contents)
258- @test occursin (" Modifying the objective function with $change " , contents)
260+ @test occursin (
261+ " Modifying the objective function with $change cannot be performed" ,
262+ contents,
263+ )
259264 @test occursin (" ## Fixing this error" , contents)
260265 return
261266end
@@ -267,26 +272,22 @@ function test_errors_show_SetAttributeNotAllowed()
267272 @test sprint (showerror, MOI. UnsupportedAttribute (MOI. Name (), " Message" )) ==
268273 " $MOI .UnsupportedAttribute{$MOI .Name}:" *
269274 " Attribute $MOI .Name() is not supported by the model: Message"
270- @test sprint (showerror, MOI. SetAttributeNotAllowed (MOI. Name ())) ==
271- " $MOI .SetAttributeNotAllowed{$MOI .Name}:" *
272- " Setting attribute $MOI .Name() cannot be performed. You may want to use" *
273- " a `CachingOptimizer` in `AUTOMATIC` mode or you may need to call" *
274- " `reset_optimizer` before doing this operation if the" *
275- " `CachingOptimizer` is in `MANUAL` mode."
276- @test sprint (
277- showerror,
278- MOI. SetAttributeNotAllowed (MOI. Name (), " Message" ),
279- ) ==
280- " $MOI .SetAttributeNotAllowed{$MOI .Name}:" *
281- " Setting attribute $MOI .Name() cannot be performed: Message You may want" *
282- " to use a `CachingOptimizer` in `AUTOMATIC` mode or you may need to call" *
283- " `reset_optimizer` before doing this operation if the `CachingOptimizer`" *
284- " is in `MANUAL` mode." ==
285- " $MOI .SetAttributeNotAllowed{$MOI .Name}:" *
286- " Setting attribute $MOI .Name() cannot be performed: Message You may want" *
287- " to use a `CachingOptimizer` in `AUTOMATIC` mode or you may need to call" *
288- " `reset_optimizer` before doing this operation if the `CachingOptimizer`" *
289- " is in `MANUAL` mode."
275+ contents = sprint (showerror, MOI. SetAttributeNotAllowed (MOI. Name ()))
276+ @test occursin (" $MOI .SetAttributeNotAllowed{$MOI .Name}:" , contents)
277+ @test occursin (
278+ " Setting attribute $(MOI. Name ()) cannot be performed" ,
279+ contents,
280+ )
281+ @test occursin (" ## Fixing this error" , contents)
282+ err = MOI. SetAttributeNotAllowed (MOI. Name (), " Message" )
283+ contents = sprint (showerror, err)
284+ @test occursin (" $(typeof (err)) " , contents)
285+ @test occursin (" Message" , contents)
286+ @test occursin (
287+ " Setting attribute $(MOI. Name ()) cannot be performed" ,
288+ contents,
289+ )
290+ @test occursin (" ## Fixing this error" , contents)
290291 return
291292end
292293
@@ -345,7 +346,10 @@ function test_get_fallback_error()
345346 err = MOI. GetAttributeNotAllowed (MOI. SolveTimeSec (), " " )
346347 contents = sprint (showerror, err)
347348 @test occursin (" $(typeof (err)) :" , contents)
348- @test occursin (" Getting attribute $(MOI. SolveTimeSec ()) " , contents)
349+ @test occursin (
350+ " Getting attribute $(MOI. SolveTimeSec ()) cannot be performed" ,
351+ contents,
352+ )
349353 @test occursin (" ## Fixing this error" , contents)
350354 return
351355end
0 commit comments