Changeset 5836


Ignore:
Timestamp:
Jun 2, 2012 6:24:36 PM (7 years ago)
Author:
wehart
Message:

Test cleanup to skip instead of simply returning.
Making baseline more generic so it works across different solvers.

Location:
coopr.opt/trunk/coopr/opt/tests/base
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • coopr.opt/trunk/coopr/opt/tests/base/test3.baseline.out

    r5835 r5836  
    2424                }
    2525            },
    26             "Status": "optimal",
    2726            "Variable": {
    2827                "x[Cabbage]": {
  • coopr.opt/trunk/coopr/opt/tests/base/test_ampl.py

    r5834 r5836  
    7676    def test3_write_mps(self):
    7777        """ Convert from AMPL to MPS """
     78        if not pyutilib.services.registered_executable("ampl"):
     79            self.skipTest("The ampl executable is not available")
    7880        self.model = AmplModel(currdir+'test3.mod')
    7981        try:
    8082            self.model.write(currdir+'test3.mps')
    8183        except pyutilib.common.ApplicationError, err:
    82             if not pyutilib.services.registered_executable("glpsol") is None:
    83                 self.fail("Unexpected ApplicationError - glpsol is enabled but not available: '%s'" % str(err))
     84            if not pyutilib.services.registered_executable("ampl") is None:
     85                self.fail("Unexpected ApplicationError - ampl is enabled but not available: '%s'" % str(err))
    8486            return
    8587        except ConverterError, err:
    86             if not pyutilib.services.registered_executable("glpsol") is None:
    87                 self.fail("Unexpected ConverterError - glpsol is enabled but not available: '%s'" % str(err))
     88            if not pyutilib.services.registered_executable("ampl") is None:
     89                self.fail("Unexpected ConverterError - ampl is enabled but not available: '%s'" % str(err))
    8890            return
    8991        self.assertFileEqualsBaseline(currdir+'test3.mps', currdir+'test3.baseline.mps', filter=filter, tolerance=1e-6)
     
    121123    def test3a_write_mps(self):
    122124        """ Convert from AMPL to MPS """
     125        if not pyutilib.services.registered_executable("ampl"):
     126            self.skipTest("The ampl executable is not available")
    123127        self.model = AmplModel(currdir+'test3a.mod', currdir+'test3a.dat')
    124128        try:
    125129            self.model.write(currdir+'test3a.mps')
    126130        except pyutilib.common.ApplicationError, err:
    127             if not pyutilib.services.registered_executable("glpsol") is None:
    128                 self.fail("Unexpected ApplicationError - glpsol is enabled but not available: '%s'" % str(err))
     131            if not pyutilib.services.registered_executable("ampl") is None:
     132                self.fail("Unexpected ApplicationError - ampl is enabled but not available: '%s'" % str(err))
    129133            return
    130134        except ConverterError, err:
    131             if not pyutilib.services.registered_executable("glpsol") is None:
    132                 self.fail("Unexpected ConverterError - glpsol is enabled but not available: '%s'" % str(err))
     135            if not pyutilib.services.registered_executable("ampl") is None:
     136                self.fail("Unexpected ConverterError - ampl is enabled but not available: '%s'" % str(err))
    133137            return
    134138        self.assertFileEqualsBaseline(currdir+'test3a.mps', currdir+'test3.baseline.mps', filter=filter, tolerance=1e-6)
     
    136140    def test3_solve(self):
    137141        if not pyutilib.services.registered_executable("glpsol"):
    138             return
     142            self.skipTest("The glpsol executable is not available")
    139143        self.model = AmplModel(currdir+'test3.mod')
    140144        opt = SolverFactory('glpk')
     
    145149    def test3a_solve(self):
    146150        if not pyutilib.services.registered_executable("glpsol"):
    147             return
     151            self.skipTest("The glpsol executable is not available")
    148152        self.model = AmplModel(currdir+'test3a.mod', currdir+'test3a.dat')
    149153        opt = SolverFactory('glpk')
Note: See TracChangeset for help on using the changeset viewer.