diff --git a/pyomo/neos/kestrel.py b/pyomo/neos/kestrel.py index 7c1518fe06f..c917a6fe7d1 100644 --- a/pyomo/neos/kestrel.py +++ b/pyomo/neos/kestrel.py @@ -207,6 +207,12 @@ def getJobAndPassword(self): password = m.groups()[0] return (jobNumber, password) + def getAvailableSolvers(self): + """Return a list of all NEOS solvers that this interface supports""" + allKestrelSolvers = self.neos.listSolversInCategory("kestrel") + _ampl = ':AMPL' + return sorted(s[: -len(_ampl)] for s in allKestrelSolvers if s.endswith(_ampl)) + def getSolverName(self): """ Read in the kestrel_options to pick out the solver name. @@ -218,12 +224,7 @@ def getSolverName(self): """ # Get a list of available kestrel solvers from NEOS - allKestrelSolvers = self.neos.listSolversInCategory("kestrel") - kestrelAmplSolvers = [] - for s in allKestrelSolvers: - i = s.find(':AMPL') - if i > 0: - kestrelAmplSolvers.append(s[0:i]) + kestrelAmplSolvers = self.getAvailableSolvers() self.options = None # Read kestrel_options to get solver name if "kestrel_options" in os.environ: diff --git a/pyomo/neos/tests/test_neos.py b/pyomo/neos/tests/test_neos.py index f14600fdb84..f55afb10439 100644 --- a/pyomo/neos/tests/test_neos.py +++ b/pyomo/neos/tests/test_neos.py @@ -98,6 +98,14 @@ def test_connection_failed(self): finally: pyomo.neos.kestrel.NEOS.host = orig_host + def test_check_all_ampl_solvers(self): + kestrel = kestrelAMPL() + solvers = kestrel.getAvailableSolvers() + for solver in solvers: + name = solver.lower().replace('-', '') + if not hasattr(RunAllNEOSSolvers, 'test_' + name): + self.fail(f"RunAllNEOSSolvers missing test for '{solver}'") + class RunAllNEOSSolvers(object): def test_bonmin(self): @@ -165,10 +173,10 @@ def test_ooqp(self): else: self._run('ooqp') - # The simple tests aren't complementarity - # problems - # def test_path(self): - # self._run('path') + def test_path(self): + # The simple tests aren't complementarity + # problems + self.skipTest("The simple NEOS test is not a complementarity problem") def test_snopt(self): self._run('snopt') diff --git a/pyomo/opt/plugins/driver.py b/pyomo/opt/plugins/driver.py index c7c7103835c..beaf5268fe9 100644 --- a/pyomo/opt/plugins/driver.py +++ b/pyomo/opt/plugins/driver.py @@ -50,7 +50,7 @@ def setup_test_parser(parser): def test_exec(options): import pyomo.solvers.tests.testcases - pyomo.solvers.tests.testcases.run_test_scenarios(options) + pyomo.solvers.tests.testcases.run_scenarios(options) # diff --git a/pyomo/solvers/tests/testcases.py b/pyomo/solvers/tests/testcases.py index 6bef40818d9..f0ea27136b6 100644 --- a/pyomo/solvers/tests/testcases.py +++ b/pyomo/solvers/tests/testcases.py @@ -355,7 +355,7 @@ def run_scenarios(options): for key, test_case in generate_scenarios(): model, solver, io = key - if len(solvers) > 0 and not solver in solvers: + if len(solvers) > 0 and solver not in solvers: continue if test_case.status == 'skip': continue @@ -381,7 +381,7 @@ def run_scenarios(options): # Validate solution status try: model_class.post_solve_test_validation(None, results) - except: + except Exception: if test_case.status == 'expected failure': stat[key] = (True, "Expected failure") else: @@ -431,7 +431,7 @@ def run_scenarios(options): total = Bunch(NumEPass=0, NumEFail=0, NumUPass=0, NumUFail=0) for key in stat: model, solver, io = key - if not solver in summary: + if solver not in summary: summary[solver] = Bunch(NumEPass=0, NumEFail=0, NumUPass=0, NumUFail=0) _pass, _str = stat[key] if _pass: