/[escript]/trunk/pyvisi/test/python/run_contour.py
ViewVC logotype

Contents of /trunk/pyvisi/test/python/run_contour.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1376 - (show annotations)
Wed Jan 9 01:38:18 2008 UTC (11 years, 6 months ago) by gross
File MIME type: text/x-python
File size: 1881 byte(s)
inserted sys.exit(1) into the tests so scons can detect the failure of the test. 
A similar statement has been removed from an earlier as it produces problems on 64bit Linux. Previously exit(0) was called in case of success but now this is not done in order to avoid a fatal end of the program. in the case of an error in the test there could be a fatal error so but I guess that this not really a problem.

PS: the fact that signal 0 was returned even for the case of an error lead to the illusion that all tests have been completed successfully.


1 from esys.pyvisi import DataCollector, Scene, Contour
2 from esys.pyvisi.constant import *
3 import unittest, os
4 from stat import ST_SIZE
5
6 try:
7 PYVISI_WORKDIR=os.environ['PYVISI_WORKDIR']
8 except KeyError:
9 PYVISI_WORKDIR='.'
10 try:
11 PYVISI_TEST_DATA_ROOT=os.environ['PYVISI_TEST_DATA_ROOT']
12 except KeyError:
13 PYVISI_TEST_DATA_ROOT='.'
14
15 PYVISI_TEST_MESHES_PATH = os.path.join(PYVISI_TEST_DATA_ROOT, "data_meshes")
16 PYVISI_TEST_CONTOUR_IMAGES_PATH = os.path.join(PYVISI_WORKDIR, \
17 "data_sample_images", "contour")
18
19 MIN_IMAGE_SIZE = 100
20 FILE_2D = "interior_2D.xml"
21 X_SIZE = 400
22 Y_SIZE = 400
23 JPG_RENDERER = Renderer.OFFLINE_JPG
24
25 class TestContour(unittest.TestCase):
26 def setUp(self):
27 self.scene = \
28 Scene(renderer = JPG_RENDERER, num_viewport = 1,
29 x_size = X_SIZE, y_size = Y_SIZE)
30
31 self.data_collector = DataCollector(source = Source.XML)
32 self.data_collector.setFileName(file_name = \
33 os.path.join(PYVISI_TEST_MESHES_PATH, FILE_2D))
34
35 self.contour = Contour(scene = self.scene,
36 data_collector = self.data_collector,
37 viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR,
38 cell_to_point = False, outline = True)
39
40 def tearDown(self):
41 del self.scene
42 del self.data_collector
43 del self.contour
44
45 def render(self, file):
46 self.scene.render(image_name = \
47 os.path.join(PYVISI_TEST_CONTOUR_IMAGES_PATH, file))
48
49 self.failUnless(os.stat(os.path.join(PYVISI_TEST_CONTOUR_IMAGES_PATH, \
50 file))[ST_SIZE] > MIN_IMAGE_SIZE)
51
52 def testGenerateContours(self):
53 self.contour.generateContours(5)
54 self.render("TestContour_testGenerateContours.jpg")
55
56
57 ##############################################################################
58
59
60 if __name__ == '__main__':
61 suite = unittest.TestSuite()
62 suite.addTest(unittest.TestLoader().loadTestsFromTestCase(TestContour))
63 s=unittest.TextTestRunner(verbosity=2).run(suite)
64 if not s.wasSuccessful(): sys.exit(1)
65
66

  ViewVC Help
Powered by ViewVC 1.1.26