Ignore:
Timestamp:
Feb 6, 2010 3:45:11 PM (10 years ago)
Author:
jwatson
Message:

Testing improvements. From lpython, the tests run individually just fine. In aggregate, only the first run passes - independent of what test that might be! Something to stare at later....

File:
1 edited

Legend:

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

    r2272 r2275  
    88from os.path import abspath, dirname
    99sys.path.insert(0, dirname(dirname(abspath(__file__)))+"/../..")
    10 curr_dir = dirname(abspath(__file__))+os.sep
     10
     11current_directory = dirname(abspath(__file__))+os.sep
    1112
    1213pysp_examples_dir = dirname(dirname(dirname(dirname(dirname(abspath(__file__))))))+os.sep+"examples"+os.sep+"pysp"+os.sep
     
    5152class TestPH(pyutilib.th.TestCase):
    5253
     54    def cleanup(self):
     55
     56        # IMPT: This step is key, as Python keys off the name of the module, not the location.
     57        #       So, different reference models in different directories won't be detected.
     58        #       If you don't do this, the symptom is a model that doesn't have the attributes
     59        #       that the data file expects.
     60        if "ReferenceModel" in sys.modules:
     61           del sys.modules["ReferenceModel"]
     62
    5363    def test_quadratic_farmer(self):
    5464
    5565        if cplex_available is False:
    5666           return
    57        
    58         pyutilib.misc.setup_redirect(curr_dir+"farmer_quadratic.out")
    5967
    60         farmer_examples_dir = pysp_examples_dir + os.sep + "farmer"
     68        pyutilib.misc.setup_redirect(current_directory+"farmer_quadratic.out")
     69        farmer_examples_dir = pysp_examples_dir + "farmer"
    6170        model_dir = farmer_examples_dir + os.sep + "models"
    6271        instance_dir = farmer_examples_dir + os.sep + "scenariodata"       
     
    6473        args = string.split(argstring)
    6574        coopr.pysp.phinit.run(args=args)
    66         pyutilib.misc.reset_redirect()       
    67         self.failUnlessFileEqualsBaseline(curr_dir+"farmer_quadratic.out",curr_dir+"farmer_quadratic.baseline", filter=filter_time)
    68 
     75        pyutilib.misc.reset_redirect()
     76        self.cleanup()       
     77        self.failUnlessFileEqualsBaseline(current_directory+"farmer_quadratic.out",current_directory+"farmer_quadratic.baseline", filter=filter_time)
     78       
    6979    def test_linearized_farmer(self):
    7080
     
    7282           return       
    7383
    74         pyutilib.misc.setup_redirect(curr_dir+"farmer_linearized.out")
    75         farmer_examples_dir = pysp_examples_dir + os.sep + "farmer"
     84        pyutilib.misc.setup_redirect(current_directory+"farmer_linearized.out")
     85        farmer_examples_dir = pysp_examples_dir + "farmer"
    7686        model_dir = farmer_examples_dir + os.sep + "models"
    7787        instance_dir = farmer_examples_dir + os.sep + "scenariodata"       
     
    7989        args = string.split(argstring)
    8090        coopr.pysp.phinit.run(args=args)       
    81         pyutilib.misc.reset_redirect()       
    82         self.failUnlessFileEqualsBaseline(curr_dir+"farmer_linearized.out",curr_dir+"farmer_linearized.baseline", filter=filter_time)
     91        pyutilib.misc.reset_redirect()
     92        self.cleanup()               
     93        self.failUnlessFileEqualsBaseline(current_directory+"farmer_linearized.out",current_directory+"farmer_linearized.baseline", filter=filter_time)
    8394
    8495    def test_quadratic_sizes3(self):
     
    8798           return
    8899       
    89         pyutilib.misc.setup_redirect(curr_dir+"sizes3_quadratic.out")
     100        pyutilib.misc.setup_redirect(current_directory+"sizes3_quadratic.out")
    90101
    91         sizes_example_dir = pysp_examples_dir + os.sep + "sizes"
     102        sizes_example_dir = pysp_examples_dir + "sizes"
    92103        model_dir = sizes_example_dir + os.sep + "models"
    93104        instance_dir = sizes_example_dir + os.sep + "SIZES3"       
     
    95106                    " --max-iterations=200"+ \
    96107                    " --rho-cfgfile="+sizes_example_dir+os.sep+"config"+os.sep+"rhosetter.cfg"+ \
    97                     " --scenario-solver-options=\"mip_tolerances_integrality=1e-7\""+ \
     108                    " --scenario-solver-options=mip_tolerances_integrality=1e-7"+ \
    98109                    " --enable-ww-extensions"+ \
    99110                    " --ww-extension-cfgfile="+sizes_example_dir+os.sep+"config"+os.sep+"wwph.cfg"+ \
    100111                    " --ww-extension-suffixfile="+sizes_example_dir+os.sep+"config"+os.sep+"wwph.suffixes"
    101         print "ARGSTRING=",argstring
    102112        args = string.split(argstring)
    103         print "ARGS=",args
    104113        coopr.pysp.phinit.run(args=args)               
    105114        pyutilib.misc.reset_redirect()
    106         print args
    107         self.failUnlessFileEqualsBaseline(curr_dir+"sizes3_quadratic.out",curr_dir+"sizes3_quadratic.baseline", filter=filter_time)       
     115        self.failUnlessFileEqualsBaseline(current_directory+"sizes3_quadratic.out",current_directory+"sizes3_quadratic.baseline", filter=filter_time)
     116        self.cleanup()       
    108117
    109118    def run(self, result=None):
Note: See TracChangeset for help on using the changeset viewer.