Skip to content

Commit cf863d4

Browse files
committed
add some tests to improve coverage
1 parent 424d05f commit cf863d4

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

test/test_model.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
import pytest
55

6+
import mip
67
from mip import (
78
CBC,
89
Column,
@@ -1315,3 +1316,31 @@ def test_remove(solver):
13151316

13161317
m.remove(constr)
13171318
m.remove(x)
1319+
1320+
@pytest.mark.parametrize("solver", SOLVERS)
1321+
def test_add_equation(solver):
1322+
m = Model(solver_name=solver)
1323+
x = m.add_var("x")
1324+
constr = m.add_constr(x == 23.5)
1325+
1326+
status = m.optimize()
1327+
assert status == OptimizationStatus.OPTIMAL
1328+
1329+
assert x.x == pytest.approx(23.5)
1330+
1331+
@pytest.mark.parametrize("solver", SOLVERS)
1332+
def test_change_objective_sense(solver):
1333+
m = Model(solver_name=solver)
1334+
x = m.add_var("x", lb=10.0, ub=20.0)
1335+
1336+
# first maximize
1337+
m.objective = mip.maximize(x)
1338+
status = m.optimize()
1339+
assert status == OptimizationStatus.OPTIMAL
1340+
assert x.x == pytest.approx(20.0)
1341+
1342+
# then minimize
1343+
m.objective = mip.minimize(x)
1344+
status = m.optimize()
1345+
assert status == OptimizationStatus.OPTIMAL
1346+
assert x.x == pytest.approx(10.0)

0 commit comments

Comments
 (0)