/[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 1376 - (show annotations)
Wed Jan 9 01:38:18 2008 UTC (13 years, 6 months ago) by gross
File MIME type: text/x-python
File size: 1876 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 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_IMAGES_PATH = os.path.join(PYVISI_WORKDIR, \
18 "data_sample_images", "logo")
19
20 MIN_IMAGE_SIZE = 100
21 LOGO = "access_logo.jpg"
22 X_SIZE = 400
23 Y_SIZE = 400
24 JPG_RENDERER = Renderer.OFFLINE_JPG
25
26 class TestLogoWithLazyEvaluation:
27 def render(self, file):
28 self.scene.render(image_name = \
29 os.path.join(PYVISI_TEST_LOGO_IMAGES_PATH, file))
30
31 self.failUnless(os.stat(os.path.join(PYVISI_TEST_LOGO_IMAGES_PATH, \
32 file))[ST_SIZE] > MIN_IMAGE_SIZE)
33
34 class TestLogo(unittest.TestCase, TestLogoWithLazyEvaluation):
35 def tearDown(self):
36 del self.scene
37
38 def testLogo(self):
39
40 # Create a Scene.
41 s = Scene(renderer = JPG_RENDERER, num_viewport = 1, x_size = X_SIZE,
42 y_size = Y_SIZE)
43 self.scene = s
44
45 # Create an ImageReader (in place of DataCollector).
46 ir = ImageReader(ImageFormat.JPG)
47
48 # Create a Logo.
49 l = Logo(scene = s, image_reader = ir, viewport = Viewport.SOUTH_WEST)
50 l.setSize(size = 0.5)
51
52 ir.setImageName(image_name = os.path.join(PYVISI_TEST_MESHES_PATH, \
53 LOGO))
54 l.setPosition(position = LocalPosition(50,60))
55
56 # Render the Logo.
57 self.render("TestLogoWithLazyEvaluation.jpg")
58
59
60 ###########################################################################
61
62
63 if __name__ == '__main__':
64 suite = unittest.TestSuite()
65 suite.addTest(unittest.TestLoader().loadTestsFromTestCase(TestLogo))
66 s=unittest.TextTestRunner(verbosity=2).run(suite)
67 if not s.wasSuccessful(): sys.exit(1)
68

  ViewVC Help
Powered by ViewVC 1.1.26