Changeset 2148


Ignore:
Timestamp:
Jan 12, 2010 1:16:37 AM (11 years ago)
Author:
wehart
Message:

Bug fixes and pyomo command tests.

Location:
coopr.pyomo/trunk/coopr/pyomo
Files:
4 added
3 edited

Legend:

Unmodified
Added
Removed
  • coopr.pyomo/trunk/coopr/pyomo/scripting/pyomo.py

    r2147 r2148  
    196196        return Container()
    197197    if not util.setup_environment(options, args):
    198         return
     198        return                                               #pragma:nocover
    199199    if not util.apply_preprocessing(options, parser, args):
    200         return Container()
     200        return Container()                                   #pragma:nocover
    201201    instance = util.create_model(options, args)
    202202    if options.only_instance:
     
    204204    results = util.apply_optimizer(options, instance)
    205205    if not util.process_results(options, instance, results):
    206         return Container(instance=instance, results=results)
     206        return Container(instance=instance, results=results) #pragma:nocover
    207207    util.apply_postprocessing(options, instance, results)
    208208    return Container(instance=instance, results=results)
  • coopr.pyomo/trunk/coopr/pyomo/scripting/util.py

    r2147 r2148  
    244244       else:
    245245          print "No solutions reported by solver."
     246    return True
    246247
    247248def apply_postprocessing(options, instance, results):
     
    311312            ans = None
    312313
    313     gc.enable()
     314    if options.disable_gc:
     315        gc.enable()
    314316    return ans
    315317
  • coopr.pyomo/trunk/coopr/pyomo/tests/examples/test_pyomo.py

    r2147 r2148  
    4141        setup_redirect(OUTPUT)
    4242        os.chdir(currdir)
    43         main.run(list(args))
     43        output = main.run(list(args))
    4444        reset_redirect()
    4545        if not 'file' in kwds:
    4646            return OUTPUT.getvalue()
     47        return output
    4748       
    4849    def test1(self):
     
    7677        self.failUnlessFileEqualsBaseline(currdir+"test6.out", currdir+"test6.txt")
    7778
     79    def Xtest7(self):
     80        """Run pyomo with help option"""
     81        self.pyomo('--help', file=currdir+'test7.out')
     82        self.failUnlessFileEqualsBaseline(currdir+"test7.out", currdir+"test7.txt")
     83
     84    def test8(self):
     85        """Run pyomo with --instance-only option"""
     86        output = self.pyomo('--instance-only pmedian.py pmedian.dat', file=currdir+'test8.out')
     87        self.failUnlessEqual(type(output.instance), Model)
     88
     89    def test9(self):
     90        """Run pyomo with --disable-gc option"""
     91        output = self.pyomo('--disable-gc pmedian.py pmedian.dat', file=currdir+'test9.out')
     92
     93    def test10(self):
     94        """Run pyomo with --verbose option"""
     95        def filter(line):
     96            #print "HERE",line
     97            return line.startswith("Writing")
     98        self.pyomo('-v pmedian.py pmedian.dat', file=currdir+'test10.out')
     99        self.failUnlessFileEqualsBaseline(currdir+"test10.out", currdir+"test10.txt", filter)
     100
     101    def test11(self):
     102        """Run pyomo with --debug=generate option"""
     103        self.pyomo('--debug=generate pmedian.py pmedian.dat', file=currdir+'test11.out')
     104        self.failUnlessFileEqualsBaseline(currdir+"test11.out", currdir+"test11.txt")
     105
     106    def test12(self):
     107        """Run pyomo with --logfile option"""
     108        self.pyomo('--debug=errors --logfile=%s pmedian.py pmedian.dat' % (currdir+'test12.log'), file=currdir+'test12.out')
     109        self.failUnlessFileEqualsBaseline(currdir+"test12.log", currdir+"test12.txt")
     110
    78111
    79112if __name__ == "__main__":
Note: See TracChangeset for help on using the changeset viewer.