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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1158 - (show annotations)
Tue May 22 04:24:01 2007 UTC (13 years, 11 months ago) by jongui
File MIME type: text/x-python
File size: 1942 byte(s)
Made some changes to fix the memory leak problem. However, the problem still persists for run_escript_with_lazy_evaluation.py, run_streamline.py and run_streamline_with_lazy_evaluation.py.

1 from esys.pyvisi import Scene, ImageReader, Logo
2 from esys.pyvisi import LocalPosition
3 from esys.pyvisi.constant import *
4 import unittest, os
5 from stat import ST_SIZE
6
7 try:
8 PYVISI_WORKDIR=os.environ['PYVISI_WORKDIR']
9 except KeyError:
10 PYVISI_WORKDIR='.'
11 try:
12 PYVISI_TEST_DATA_ROOT=os.environ['PYVISI_TEST_DATA_ROOT']
13 except KeyError:
14 PYVISI_TEST_DATA_ROOT='.'
15
16 PYVISI_TEST_MESHES_PATH = os.path.join(PYVISI_TEST_DATA_ROOT, "data_meshes")
17 PYVISI_TEST_LOGO_REFERENCE_IMAGES_PATH = os.path.join(PYVISI_TEST_DATA_ROOT, \
18 "data_reference_images", "logo")
19 PYVISI_TEST_LOGO_IMAGES_PATH = os.path.join(PYVISI_WORKDIR, \
20 "data_sample_images", "logo")
21
22 MIN_IMAGE_SIZE = 100
23 LOGO = "access_logo.jpg"
24 X_SIZE = 400
25 Y_SIZE = 400
26 JPG_RENDERER = Renderer.OFFLINE_JPG
27
28 class TestLogoWithLazyEvaluation:
29 def render(self, file):
30 self.scene.render(image_name = \
31 os.path.join(PYVISI_TEST_LOGO_IMAGES_PATH, file))
32
33 self.failUnless(os.stat(os.path.join(PYVISI_TEST_LOGO_IMAGES_PATH, \
34 file))[ST_SIZE] > MIN_IMAGE_SIZE)
35
36 class TestLogo(unittest.TestCase, TestLogoWithLazyEvaluation):
37 def tearDown(self):
38 del self.scene
39
40 def testLogo(self):
41
42 # Create a Scene.
43 s = Scene(renderer = JPG_RENDERER, num_viewport = 1, x_size = X_SIZE,
44 y_size = Y_SIZE)
45 self.scene = s
46
47 # Create an ImageReader (in place of DataCollector).
48 ir = ImageReader(ImageFormat.JPG)
49
50 # Create a Logo.
51 l = Logo(scene = s, image_reader = ir, viewport = Viewport.SOUTH_WEST)
52 l.setSize(size = 0.5)
53
54 ir.setImageName(image_name = os.path.join(PYVISI_TEST_MESHES_PATH, \
55 LOGO))
56 l.setPosition(position = LocalPosition(50,60))
57
58 # Render the Logo.
59 self.render("TestLogoWithLazyEvaluation.jpg")
60
61
62 ###########################################################################
63
64
65 if __name__ == '__main__':
66 suite = unittest.TestSuite()
67 suite.addTest(unittest.TestLoader().loadTestsFromTestCase(TestLogo))
68 unittest.TextTestRunner(verbosity=2).run(suite)
69

  ViewVC Help
Powered by ViewVC 1.1.26