source: trunk/test/pyomo/examples/test_tutorials.py @ 1101

Last change on this file since 1101 was 1101, checked in by wehart, 12 years ago

Update to baseline data used for testing.

File size: 1.8 KB
Line 
1#
2# Unit Tests for Pyomo tutorials
3#
4
5import unittest
6import os
7import sys
8from os.path import abspath, dirname
9topdir = dirname(dirname(abspath(__file__)))+os.sep+".."+os.sep+".."
10sys.path.insert(0, topdir)
11currdir = dirname(abspath(__file__))+os.sep
12tutorial_dir=topdir+os.sep+"examples"+os.sep+"pyomo"+os.sep+"tutorials"+os.sep
13
14from coopr.pyomo import *
15import pyutilib
16import pyutilib_th
17
18try:
19  from win32com.client.dynamic import Dispatch
20  _win32com=True
21except:
22  _win32com=False #pragma:nocover
23
24class PyomoTutorials(pyutilib_th.TestCase):
25
26    def setUp(self):
27        pass
28
29    def construct(self,filename):
30        pass
31
32    def test_data(self):
33        pyutilib.run_file(tutorial_dir+"data.py", logfile=currdir+"data.log", execdir=tutorial_dir)
34        self.failUnlessFileEqualsBaseline(currdir+"data.log", tutorial_dir+"data.out")
35
36    def test_excel(self):
37        if not _win32com:
38           return
39        pyutilib.run_file(tutorial_dir+"excel.py", logfile=currdir+"excel.log", execdir=tutorial_dir)
40        self.failUnlessFileEqualsBaseline(currdir+"excel.log", tutorial_dir+"excel.out")
41
42    def test_set(self):
43        pyutilib.run_file(tutorial_dir+"set.py", logfile=currdir+"set.log", execdir=tutorial_dir)
44        self.failUnlessFileEqualsBaseline(currdir+"set.log", tutorial_dir+"set.out")
45
46    def test_table(self):
47        pyutilib.run_file(tutorial_dir+"table.py", logfile=currdir+"table.log", execdir=tutorial_dir)
48        self.failUnlessFileEqualsBaseline(currdir+"table.log", tutorial_dir+"table.out")
49
50    def test_param(self):
51        pyutilib.run_file(tutorial_dir+"param.py", logfile=currdir+"param.log", execdir=tutorial_dir)
52        self.failUnlessFileEqualsBaseline(currdir+"param.log", tutorial_dir+"param.out")
53
54if __name__ == "__main__":
55   unittest.main()
Note: See TracBrowser for help on using the repository browser.