/[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 1138 - (show annotations)
Mon May 14 04:15:04 2007 UTC (13 years, 6 months ago) by gross
File MIME type: text/x-python
File size: 1838 byte(s)
 * some of the sys.exit calls removed.
 * some modifications on the test (and more work needs to be done, use test/python/run_carpet.py as an example) to get them going with scons 

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

  ViewVC Help
Powered by ViewVC 1.1.26