From 16ccf045d6366c69984c4ac72b59c587ac76daa2 Mon Sep 17 00:00:00 2001 From: Matt Haberland Date: Sun, 28 May 2023 17:19:30 -0700 Subject: [PATCH] TST: minimize_ipopt: don't run new tests if SciPy isn't available --- cyipopt/tests/unit/test_scipy_ipopt_from_scipy.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/cyipopt/tests/unit/test_scipy_ipopt_from_scipy.py b/cyipopt/tests/unit/test_scipy_ipopt_from_scipy.py index 2193a12f..966782b6 100644 --- a/cyipopt/tests/unit/test_scipy_ipopt_from_scipy.py +++ b/cyipopt/tests/unit/test_scipy_ipopt_from_scipy.py @@ -2,10 +2,16 @@ Unit tests written for scipy.optimize.minimize method='SLSQP'; adapted for minimize_ipopt """ +import sys +import pytest from numpy.testing import (assert_, assert_allclose) import numpy as np -from scipy.optimize import Bounds, NonlinearConstraint +try: + from scipy.optimize import Bounds +except ImportError: + pass + from cyipopt import minimize_ipopt as minimize @@ -23,6 +29,8 @@ def __call__(self, x): self.ncalls += 1 +@pytest.mark.skipif("scipy" not in sys.modules, + reason="Test only valid if Scipy available.") class TestSLSQP: """ Test SLSQP algorithm using Example 14.4 from Numerical Methods for @@ -288,7 +296,8 @@ def test_invalid_bounds(self): ] for bounds in bounds_list: res = minimize(self.fun, [-1.0, 1.0], bounds=bounds, method=None) - assert res.status == -11 # invalid problem definition + # "invalid problem definition" or "problem may be infeasible" + assert res.status == -11 or res.status == 2 def test_bounds_clipping(self): #