Go to the documentation of this file.00001 import os
00002 import string
00003 import sys
00004 import shutil
00005 import unittest
00006 from __main__ import default
00007 from tasks import *
00008 from taskinit import *
00009
00010 '''
00011 Unit tests for task plotuv. It tests the following parameters:
00012 vis: wrong and correct values
00013 figfile: if output is created
00014 '''
00015 class plotuv_test(unittest.TestCase):
00016
00017 datapath = os.environ.get('CASAPATH').split()[0] + '/data/regression/ic2233/'
00018 msfile = datapath + 'ic2233_1.ms'
00019 res = None
00020 fig = 'plotuvtest.png'
00021
00022 def setUp(self):
00023 self.res = None
00024 default(plotuv)
00025
00026 def tearDown(self):
00027 pass
00028
00029 def test0(self):
00030 '''Test 0: Default parameters'''
00031 self.res = plotuv()
00032 self.assertFalse(self.res)
00033
00034 def test1(self):
00035 '''Test 1: Bad input file'''
00036 msfile = 'badfile'
00037 self.res = plotuv(vis=msfile)
00038 self.assertFalse(self.res)
00039
00040 def test2(self):
00041 '''Test 2: Good input file and output exists'''
00042 if os.uname()[0] == "Darwin" and \
00043 os.system("sw_vers -productVersion | grep 10.6") == 0 and \
00044 not os.getenv("DISPLAY"):
00045 print >> sys.stderr, "Warning: The DISPLAY environment variable is unset, " + \
00046 "required on OS X 10.6, skipping test"
00047 else:
00048 self.res = plotuv(vis=self.msfile, figfile=self.fig)
00049 self.assertTrue(self.res)
00050 expfigparts = self.fig.split('.')
00051 expfig = '.'.join(expfigparts[:-1]) + '_fld0.' + expfigparts[-1]
00052 self.assertTrue(os.path.exists(expfig))
00053 os.unlink(expfig)
00054
00055 def suite():
00056 return [plotuv_test]
00057
00058
00059
00060
00061
00062
00063