diff --git a/src/Test/test_model.jl b/src/Test/test_model.jl index d315ac4f55..96f5358e42 100644 --- a/src/Test/test_model.jl +++ b/src/Test/test_model.jl @@ -748,16 +748,18 @@ function test_model_ScalarFunctionConstantNotZero( try f = MOI.ScalarAffineFunction(MOI.ScalarAffineTerm{T}[], T(1)) c = MOI.add_constraint(model, f, MOI.EqualTo(T(2))) - @requires _supports(config, MOI.ConstraintFunction) - @test MOI.get(model, MOI.ConstraintFunction(), c) ≈ f + if _supports(config, MOI.ConstraintFunction) + @test MOI.get(model, MOI.ConstraintFunction(), c) ≈ f + end catch err @test err == _error(MOI.EqualTo{T}, T(1)) end try f = MOI.ScalarAffineFunction(MOI.ScalarAffineTerm{T}[], T(2)) c = MOI.add_constraint(model, f, MOI.GreaterThan(T(1))) - @requires _supports(config, MOI.ConstraintFunction) - @test MOI.get(model, MOI.ConstraintFunction(), c) ≈ f + if _supports(config, MOI.ConstraintFunction) + @test MOI.get(model, MOI.ConstraintFunction(), c) ≈ f + end catch err @test err == _error(MOI.GreaterThan{T}, T(2)) end diff --git a/test/Test/Test.jl b/test/Test/Test.jl index 161187974d..9859213075 100644 --- a/test/Test/Test.jl +++ b/test/Test/Test.jl @@ -38,6 +38,16 @@ MOI.Test.runtests( ], ) +# Test for Issue #1757 + +MOI.Test.test_model_ScalarFunctionConstantNotZero( + MOI.Utilities.MockOptimizer( + MOI.Utilities.Model{Float64}(), + scalar_function_constant_non_zero = false, + ), + MOI.Test.Config(exclude = Any[MOI.ConstraintFunction]), +) + # Test exclude_tests_after. This should work despite no methods being added for IncompleteOptimizer # because every test should get skipped.