Skip to content

Commit

Permalink
Make solution print test more reliable
Browse files Browse the repository at this point in the history
  • Loading branch information
mmghannam committed Nov 13, 2023
1 parent c57ad29 commit 14c8486
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions tests/test_solution.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import re
import pytest
from pyscipopt import Model, scip, SCIP_PARAMSETTING, quicksum, quickprod

Expand Down Expand Up @@ -124,13 +125,14 @@ def test_create_solution():
with pytest.raises(ValueError):
scip.Solution()

def test_print_soltion():
def test_print_solution():
m = Model()

m.addVar()
m.addVar(obj=1, name="x")
m.optimize()

assert str(m.getBestSol()) == "{'x1': -0.0}"
solution_str = str(m.getBestSol())
print(re.match(r"{'x': -?\d+\.?\d*}", solution_str) is not None)

def test_getSols():
m = Model()
Expand Down

0 comments on commit 14c8486

Please sign in to comment.