Skip to content

Commit

Permalink
fixed gurobi wrapper being used with other solvers (#728)
Browse files Browse the repository at this point in the history
* fixed gurobi wrapper being used with other solvers

* forgot an argument

* black linting
  • Loading branch information
pchtsp authored Jan 29, 2024
1 parent cfde9c6 commit eab9799
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions doc/KPyCon2009/code/whiskas.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Example problem file that solves the whiskas blending problem
"""

import pulp

# initialise the model
Expand Down
1 change: 1 addition & 0 deletions examples/furniture.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
The Furniture problem from EngSci391 for the PuLP Modeller
Author: Dr Stuart Mitchell 2007
"""

from pulp import *

Chairs = ["A", "B"]
Expand Down
9 changes: 6 additions & 3 deletions pulp/tests/test_pulp.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""
Tests for pulp
"""
import os

import tempfile

from pulp.constants import PulpError
Expand Down Expand Up @@ -45,11 +45,14 @@

def gurobi_test(test_item):
@functools.wraps(test_item)
def skip_wrapper(*args, **kwargs):
def skip_wrapper(test_obj, *args, **kwargs):
if not test_obj.solver.name in ["GUROBI", "GUROBI_CMD"]:
# if we're not testing gurobi, we do not care on the licence
return test_item(test_obj, *args, **kwargs)
if gp is None:
raise unittest.SkipTest("No gurobipy, can't check license")
try:
test_item(*args, **kwargs)
return test_item(test_obj, *args, **kwargs)
except gp.GurobiError as ge:
# Skip the test if the failure was due to licensing
if ge.errno == gp.GRB.Error.SIZE_LIMIT_EXCEEDED:
Expand Down

0 comments on commit eab9799

Please sign in to comment.