/[escript]/trunk/escriptcore/test/python/test_modulefns.py
ViewVC logotype

Contents of /trunk/escriptcore/test/python/test_modulefns.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4938 - (show annotations)
Wed May 14 01:13:23 2014 UTC (5 years, 3 months ago) by jfenwick
File MIME type: text/x-python
File size: 2477 byte(s)
Modify unit tests to read their classes from
esys.escriptcore.utestselect

Change the line in that file to switch between unittest and unittest2


1
2 ##############################################################################
3 #
4 # Copyright (c) 2009-2014 by University of Queensland
5 # http://www.uq.edu.au
6 #
7 # Primary Business: Queensland, Australia
8 # Licensed under the Open Software License version 3.0
9 # http://www.opensource.org/licenses/osl-3.0.php
10 #
11 # Development until 2012 by Earth Systems Science Computational Center (ESSCC)
12 # Development 2012-2013 by School of Earth Sciences
13 # Development from 2014 by Centre for Geoscience Computing (GeoComp)
14 #
15 ##############################################################################
16
17 __copyright__="""Copyright (c) 2009-2014 by University of Queensland
18 http://www.uq.edu.au
19 Primary Business: Queensland, Australia"""
20 __license__="""Licensed under the Open Software License version 3.0
21 http://www.opensource.org/licenses/osl-3.0.php"""
22 __url__="https://launchpad.net/escript-finley"
23
24 import esys.escriptcore.utestselect as unittest
25 import esys.escript
26 import sys
27
28 #Just because we are unit testing these functions does not mean we encourage their use.
29 #In many cases these tests are merely testing if the call works, not if it does what
30 #you might expect
31
32 class ModuleFnsTestCase(unittest.TestCase):
33
34 def setUp(self):
35 pass
36
37 def testGlobalMax(self):
38 r=esys.escript.getMPIRankWorld()
39 self.assertEqual(esys.escript.getMPISizeWorld()-1,esys.escript.getMPIWorldMax(r))
40
41
42 def testGlobalSum(self):
43 r=esys.escript.getMPIRankWorld()
44 s=esys.escript.getMPISizeWorld()
45 total=s/2.0*(1+s)-s
46 self.assertEqual(total,esys.escript.getMPIWorldSum(r))
47
48 def testgetMachinePrecision(self):
49 if esys.escript.getMachinePrecision()>1: #Arbitrary value
50 self.fail("Machine precision is not sensible")
51
52 def testMPIBarrier(self):
53 esys.escript.MPIBarrierWorld()
54
55 def testgetMaxFloat(self):
56 self.assertTrue(esys.escript.getMaxFloat()>1) #Arbitrary value
57
58 def testprintParallelThreadCounts(self):
59 esys.escript.printParallelThreadCounts()
60
61 def testgetNumberOfThreads(self):
62 self.assertTrue(esys.escript.getNumberOfThreads()>=1)
63
64
65 def testgetSvnVersion(self):
66 esys.escript.getVersion()
67
68 if __name__ == "__main__":
69 suite = unittest.TestSuite()
70 suite.addTest(unittest.makeSuite(ModuleFnsTestCase))
71 s=unittest.TextTestRunner(verbosity=2).run(suite)
72 if not s.wasSuccessful(): sys.exit(1)

  ViewVC Help
Powered by ViewVC 1.1.26