From 87cc43eecc55fe942c6a6534b591c8979770cdb4 Mon Sep 17 00:00:00 2001 From: Qi Chen Date: Wed, 17 Apr 2019 15:41:48 -0400 Subject: [PATCH] Add license guard --- pyomo/contrib/gdpopt/tests/test_gdpopt.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pyomo/contrib/gdpopt/tests/test_gdpopt.py b/pyomo/contrib/gdpopt/tests/test_gdpopt.py index eb0e6054421..f77e926cd54 100644 --- a/pyomo/contrib/gdpopt/tests/test_gdpopt.py +++ b/pyomo/contrib/gdpopt/tests/test_gdpopt.py @@ -31,6 +31,7 @@ GLOA_solvers = (mip_solver, global_nlp_solver, minlp_solver) LOA_solvers_available = all(SolverFactory(s).available() for s in LOA_solvers) GLOA_solvers_available = all(SolverFactory(s).available() for s in GLOA_solvers) +license_available = SolverFactory(global_nlp_solver).license_is_valid() if GLOA_solvers_available else False class TestGDPoptUnit(unittest.TestCase): @@ -385,6 +386,7 @@ def test_GDP_integer_vars_infeasible(self): ) self.assertEqual(res.solver.termination_condition, TerminationCondition.infeasible) + @unittest.skipUnless(license_available, "Global NLP solver license not available.") def test_GLOA_8PP(self): """Test the global logic-based outer approximation algorithm.""" exfile = import_file( @@ -398,6 +400,7 @@ def test_GLOA_8PP(self): ) self.assertTrue(fabs(value(eight_process.profit.expr) - 68) <= 1E-2) + @unittest.skipUnless(license_available, "Global NLP solver license not available.") def test_GLOA_8PP_force_NLP(self): """Test the global logic-based outer approximation algorithm.""" exfile = import_file( @@ -412,6 +415,7 @@ def test_GLOA_8PP_force_NLP(self): ) self.assertTrue(fabs(value(eight_process.profit.expr) - 68) <= 1E-2) + @unittest.skipUnless(license_available, "Global NLP solver license not available.") def test_GLOA_strip_pack_default_init(self): """Test logic-based outer approximation with strip packing.""" exfile = import_file( @@ -425,6 +429,7 @@ def test_GLOA_strip_pack_default_init(self): self.assertTrue( fabs(value(strip_pack.total_length.expr) - 11) <= 1E-2) + @unittest.skipUnless(license_available, "Global NLP solver license not available.") def test_GLOA_constrained_layout_default_init(self): """Test LOA with constrained layout.""" exfile = import_file(