@@ -27,12 +27,10 @@ function test_errors_fallback_AddVariableNotAllowed()
27
27
try
28
28
MOI. add_variable (model)
29
29
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)
36
34
end
37
35
@test_throws MOI. AddVariableNotAllowed MOI. add_variables (model, 2 )
38
36
return
@@ -104,13 +102,14 @@ function test_errors_add_constraint()
104
102
try
105
103
MOI. add_constraint (model, vi, MOI. EqualTo (0.0 ))
106
104
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)
114
113
end
115
114
@test_throws (
116
115
MOI. AddConstraintNotAllowed,
@@ -141,7 +140,7 @@ function test_errors_DeleteNotAllowed()
141
140
catch err
142
141
contents = sprint (showerror, err)
143
142
@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)
145
144
@test occursin (" ## Fixing this error" , contents)
146
145
end
147
146
@test_throws MOI. DeleteNotAllowed{typeof (ci)} MOI. delete (model, ci)
@@ -150,7 +149,7 @@ function test_errors_DeleteNotAllowed()
150
149
catch err
151
150
contents = sprint (showerror, err)
152
151
@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)
154
153
@test occursin (" ## Fixing this error" , contents)
155
154
end
156
155
return
@@ -242,7 +241,10 @@ function test_errors_ModifyNotAllowed_constraint()
242
241
@test_throws err MOI. modify (model, ci, change)
243
242
contents = sprint (showerror, err)
244
243
@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
+ )
246
248
@test occursin (" ## Fixing this error" , contents)
247
249
return
248
250
end
@@ -255,7 +257,10 @@ function test_errors_ModifyNotAllowed_objective()
255
257
@test_throws err MOI. modify (model, attr, change)
256
258
contents = sprint (showerror, err)
257
259
@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
+ )
259
264
@test occursin (" ## Fixing this error" , contents)
260
265
return
261
266
end
@@ -267,26 +272,22 @@ function test_errors_show_SetAttributeNotAllowed()
267
272
@test sprint (showerror, MOI. UnsupportedAttribute (MOI. Name (), " Message" )) ==
268
273
" $MOI .UnsupportedAttribute{$MOI .Name}:" *
269
274
" 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)
290
291
return
291
292
end
292
293
@@ -345,7 +346,10 @@ function test_get_fallback_error()
345
346
err = MOI. GetAttributeNotAllowed (MOI. SolveTimeSec (), " " )
346
347
contents = sprint (showerror, err)
347
348
@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
+ )
349
353
@test occursin (" ## Fixing this error" , contents)
350
354
return
351
355
end
0 commit comments