Skip to content

Commit

Permalink
update tests to guard against AmplInterface not available
Browse files Browse the repository at this point in the history
  • Loading branch information
Robbybp committed Nov 1, 2022
1 parent d8de0d0 commit 6bd08c4
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@
if not scipy_available:
raise unittest.SkipTest("SciPy is needed to test the SciPy solvers")

from pyomo.contrib.pynumero.asl import AmplInterface
if not AmplInterface.available():
raise unittest.SkipTest(
"Pynumero needs the ASL extension to run SciPy solver tests"
)

from pyomo.contrib.pynumero.interfaces.pyomo_nlp import PyomoNLP
from pyomo.contrib.pynumero.algorithms.solvers.square_solver_base import (
SquareNlpSolverBase,
Expand All @@ -40,6 +46,7 @@ def make_simple_model():


@unittest.skipUnless(scipy_available, "SciPy is not available")
@unittest.skipUnless(AmplInterface.available(), "AmplInterface is not available")
class TestSquareSolverBase(unittest.TestCase):

def test_not_implemented_solve(self):
Expand Down Expand Up @@ -68,6 +75,7 @@ def test_bounds_and_ineq_okay(self):


@unittest.skipUnless(scipy_available, "SciPy is not available")
@unittest.skipUnless(AmplInterface.available(), "AmplInterface is not available")
class TestFsolveNLP(unittest.TestCase):

def test_solve_simple_nlp(self):
Expand Down Expand Up @@ -115,6 +123,7 @@ def test_solve_too_tight_tol(self):


@unittest.skipUnless(scipy_available, "SciPy is not available")
@unittest.skipUnless(AmplInterface.available(), "AmplInterface is not available")
class TestPyomoScipySolver(unittest.TestCase):

def test_available_and_version(self):
Expand All @@ -129,6 +138,7 @@ def test_available_and_version(self):


@unittest.skipUnless(scipy_available, "SciPy is not available")
@unittest.skipUnless(AmplInterface.available(), "AmplInterface is not available")
class TestFsolvePyomo(unittest.TestCase):

def test_available_and_version(self):
Expand Down Expand Up @@ -198,6 +208,7 @@ def test_solve_too_tight_tol(self):


@unittest.skipUnless(scipy_available, "SciPy is not available")
@unittest.skipUnless(AmplInterface.available(), "AmplInterface is not available")
class TestRootNLP(unittest.TestCase):

def test_solve_simple_nlp(self):
Expand All @@ -220,6 +231,7 @@ def test_solve_simple_nlp(self):


@unittest.skipUnless(scipy_available, "SciPy is not available")
@unittest.skipUnless(AmplInterface.available(), "AmplInterface is not available")
class TestRootPyomo(unittest.TestCase):

def test_available_and_version(self):
Expand Down

0 comments on commit 6bd08c4

Please sign in to comment.