Changeset 2665


Ignore:
Timestamp:
Jun 16, 2010 10:48:04 AM (11 years ago)
Author:
wehart
Message:

Various updates and fixes. I think that the coopr_driver plugin is now correctly called.

Location:
coopr.testing/trunk/coopr/testing
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • coopr.testing/trunk/coopr/testing/coopr_driver.py

    r2660 r2665  
    11
    22import plugins
     3import coopr.opt
    34from pyutilib.component.core import *
    45
     
    910    alias('coopr')
    1011
    11     def run_test(self, options):
    12         print "Running coopr.opt solver with options",options
     12    def setUp(self, testcase, options):
     13        options._opt = coopr.opt.SolverFactory(options.solver, options=options.solver_options, suffixes=['.*'])
     14        if options._opt is None:
     15            self.skipTest('Solver %s is not available' % options.solver)
     16
     17    def tearDown(self, testcase, options):
     18        pass
     19
     20    def run_test(self, testcase, name, options):
     21        print "Test %s - Running coopr.opt solver with options %s" % (name, str(options))
     22        results = self.cplex.solve(options.problem, logfile=options.currdir+name+".log")
     23        results.write(filename=options.currdir+name+".txt",times=False)
     24        self.failUnlessFileEqualsBaseline(currdir+name+".txt", options.baseline)
    1325        return ""
    1426
  • coopr.testing/trunk/coopr/testing/driver.py

    r2660 r2665  
    2424            raise IOError, "Expected dictionary of solvers"
    2525        for key in suite['solvers']:
    26             if not type(suite['solvers'][key]) is dict:
    27                 raise IOError, "Expected solvers to have a dictionary of options"
     26            if suite['solvers'][key] is None:
     27                suite['solvers'][key] = {}
     28            elif not type(suite['solvers'][key]) is dict:
     29                raise IOError, "Expected solvers to have a dictionary of options: %s" % str(suite)
    2830    #
    2931    if 'problems' in suite:
     
    3133            raise IOError, "Expected dictionary of problems"
    3234        for key in suite['problems']:
    33             if not type(suite['problems'][key]) is dict:
     35            if suite['problems'][key] is None:
     36                suite['problems'][key] = {}
     37            elif not type(suite['problems'][key]) is dict:
    3438                raise IOError, "Expected problems to have a dictionary of options"
    3539    #
     
    3842            raise IOError, "Expected dictionary of suites"
    3943        for key in suite['suites']:
    40             if not type(suite['suites'][key]) is dict:
     44            if suite['suites'][key] is None:
     45                suite['suites'][key] = {}
     46            elif not type(suite['suites'][key]) is dict:
    4147                raise IOError, "Expected suites to have a dictionary of options"
    4248
     
    104110            options.solver = sname
    105111            options.problem = problem
    106             def fn(name):
    107                 return test_driver.run_test(name, fn._options)
     112            def fn(testcase, name):
     113                test_driver.setUp(testcase, fn._options)
     114                ans = test_driver.run_test(testcase, name, fn._options)
     115                test_driver.tearDown(testcase, fn._options)
     116                return ans
    108117            fn._options = options
    109118            _globals["TestSuite_"+suite].add_fn_test(name=test_name, fn=fn)
     
    161170    print "X",sys.argv
    162171    print "X",globals().keys()
    163     print "X",dir(globals()['TestSuite_ps'])
    164172    print dir(globals()['__name__'])
    165173    unittest.main(module=globals()['__name__'])
  • coopr.testing/trunk/coopr/testing/plugins.py

    r2660 r2665  
    1515class ITestDriver(Interface):
    1616
    17     def run_test(self, options):
     17    def run_test(self, testcase, name, options):
     18        pass
     19
     20    def setUp(self, testcase, options):
     21        pass
     22
     23    def tearDown(self, testcase, options):
    1824        pass
    1925
  • coopr.testing/trunk/coopr/testing/pyomo_driver.py

    r2660 r2665  
    1010
    1111    def run_test(self, options):
    12         print "Running Pyomo with options",options
     12        print "Test %s - Running Pyomo with options %s" % (name, str(options))
     13        return ""
    1314
Note: See TracChangeset for help on using the changeset viewer.