Changeset 2423


Ignore:
Timestamp:
Mar 11, 2010 6:01:10 PM (9 years ago)
Author:
wehart
Message:

Rework of unit tests to (a) import pyutilib.th as 'unittest' and
(b) employ test skipping.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • coopr.pysp/trunk/coopr/pysp/tests/unit/test_ph.py

    r2382 r2423  
    1818# Import the testing packages
    1919#
    20 import unittest
    2120import pyutilib.misc
    22 import pyutilib.th
     21import pyutilib.th as unittest
    2322import pyutilib.subprocess
    2423import coopr.pysp
     
    4645
    4746#
    48 # Define a testing class, using the pyutilib.th.TestCase class.  This is
    49 # an extension of the unittest.TestCase class that adds additional testing
    50 # functions.
     47# Define a testing class, using the unittest.TestCase class.
    5148#
    52 class TestPH(pyutilib.th.TestCase):
     49class TestPH(unittest.TestCase):
    5350
    5451    def cleanup(self):
     
    6158           del sys.modules["ReferenceModel"]
    6259
     60    @unittest.skipIf(not cplex_available, "The 'cplex' executable is not available")
    6361    def test_quadratic_farmer(self):
    64 
    65         if cplex_available is False:
    66            return
    67 
    6862        pyutilib.misc.setup_redirect(current_directory+"farmer_quadratic.out")
    6963        farmer_examples_dir = pysp_examples_dir + "farmer"
     
    7771        self.failUnlessFileEqualsBaseline(current_directory+"farmer_quadratic.out",current_directory+"farmer_quadratic.baseline", filter=filter_time)
    7872       
     73    @unittest.skipIf(not cplex_available, "The 'cplex' executable is not available")
    7974    def test_linearized_farmer(self):
    80 
    81         solver_string = ""
    8275        if cplex_available:
    8376            solver_string="cplex"
    84         #elif glpk_available:
    85             #solver_string="glpk"
    86         else:
    87            return
    88 
    8977        pyutilib.misc.setup_redirect(current_directory+"farmer_linearized.out")
    9078        farmer_examples_dir = pysp_examples_dir + "farmer"
     
    9886        self.failUnlessFileEqualsBaseline(current_directory+"farmer_linearized.out",current_directory+"farmer_linearized.baseline", filter=filter_time)
    9987
     88    @unittest.skipIf(not cplex_available, "The 'cplex' executable is not available")
    10089    def test_linearized_farmer_nodedata(self):
    101 
    102         solver_string = ""
    10390        if cplex_available:
    10491            solver_string="cplex"
    105         #elif glpk_available:
    106             #solver_string="glpk"
    107         else:
    108            return
    109 
    11092        pyutilib.misc.setup_redirect(current_directory+"farmer_linearized_nodedata.out")
    11193        farmer_examples_dir = pysp_examples_dir + "farmer"
     
    119101        self.failUnlessFileEqualsBaseline(current_directory+"farmer_linearized_nodedata.out",current_directory+"farmer_linearized_nodedata.baseline", filter=filter_time)       
    120102
     103    @unittest.skipIf(not cplex_available, "The 'cplex' executable is not available")
    121104    def test_quadratic_sizes3(self):
    122105
    123106        # Ignore this for now
    124107        return
    125 
    126         if cplex_available is False:
    127            return
    128108       
    129109        pyutilib.misc.setup_redirect(current_directory+"sizes3_quadratic.out")
     
    146126
    147127if __name__ == "__main__":
    148    unittest.main()
     128    unittest.main()
Note: See TracChangeset for help on using the changeset viewer.