def test_set_problem_format(self): opt = pyomo.opt.SolverFactory("stest1") opt._valid_problem_formats = [] try: opt.set_problem_format('a') except ValueError: pass else: self.fail("Should not be able to set the problem format undless it's declared as valid.") opt._valid_problem_formats = ['a'] self.assertEqual(opt.results_format(), None) opt.set_problem_format('a') self.assertEqual(opt.problem_format(), 'a') self.assertEqual(opt.results_format(), opt._default_results_format('a'))
def test_set_results_format(self): opt = pyomo.opt.SolverFactory("stest1") opt._valid_problem_formats = ['a'] opt._valid_results_formats = {'a': 'b'} self.assertEqual(opt.problem_format(), None) try: opt.set_results_format('b') except ValueError: pass else: self.fail("Should not be able to set the results format unless it's "\ "declared as valid for the current problem format.") opt.set_problem_format('a') self.assertEqual(opt.problem_format(), 'a') opt.set_results_format('b') self.assertEqual(opt.results_format(), 'b')
def test_set_results_format(self): opt = pyomo.opt.SolverFactory("stest1") opt._valid_problem_formats = ['a'] opt._valid_results_formats = {'a':'b'} self.assertEqual(opt.problem_format(), None) try: opt.set_results_format('b') except ValueError: pass else: self.fail("Should not be able to set the results format unless it's "\ "declared as valid for the current problem format.") opt.set_problem_format('a') self.assertEqual(opt.problem_format(), 'a') opt.set_results_format('b') self.assertEqual(opt.results_format(), 'b')
def test_results_format(self): opt = pyomo.opt.SolverFactory("stest1") opt._results_format = 'a' self.assertEqual(opt.results_format(), 'a') opt._results_format = None self.assertEqual(opt.results_format(), None)