~fluidity-core/fluidity/embedded_models

« back to all changes in this revision

Viewing changes to libspud/diamond/tests/plist/plist.py

  • Committer: Timothy Bond
  • Date: 2011-04-14 15:40:24 UTC
  • Revision ID: timothy.bond@imperial.ac.uk-20110414154024-116ci9gq6mwigmaw
Following the move from svn to bzr we change the nature of inclusion of these
four software libraries. Previously, they were included as svn externals and
pulled at latest version for trunk, pinned to specific versions for release
and stable trunk. Since bzr is less elegant at dealing with externals we have
made the decision to include the packages directly into the trunk instead.

At this import the versions are:

libadaptivity: r163
libvtkfortran: r67
libspud: r545
libmba2d: r28

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env python
 
2
 
 
3
import diamond.plist as plist
 
4
import unittest
 
5
 
 
6
class PyListModule(unittest.TestCase):
 
7
 
 
8
        ''' #1: A simple list of integers, with cardinality ''. (One element only). '''
 
9
        def testSimple(self):
 
10
                l = plist.List(int)
 
11
                self.assertEqual(l.__str__(), "list of <type 'int'> of cardinality: ")
 
12
                self.assertEqual(l.__repr__(), "list of <type 'int'> of cardinality: ")
 
13
                self.assertEqual(l("0"), "0")
 
14
 
 
15
        ''' #2: A simple list of integers, with cardinality '+'. '''
 
16
        def testOneOrMore(self):
 
17
                l = plist.List(int, '+')
 
18
                self.assertEqual(l.__str__(), "list of <type 'int'> of cardinality: +")
 
19
                self.assertEqual(l.__repr__(), "list of <type 'int'> of cardinality: +")
 
20
                self.assertEqual(l("3,4,5"), "3 4 5")
 
21
 
 
22
        ''' #3: A list of two strings, with cardinality 2. '''
 
23
        def testTwoStrings(self):
 
24
                l = plist.List(str, "2")
 
25
                self.assertEqual(l.__str__(), "list of <type 'str'> of cardinality: 2")
 
26
                self.assertEqual(l.__repr__(), "list of <type 'str'> of cardinality: 2")
 
27
                self.assertEqual(l("first second"), "first second")
 
28
 
 
29
        ''' #4: A list of none type, which should throw an non-callable exception when called. '''
 
30
        def testNoneType(self):
 
31
                l = plist.List(None)
 
32
                try:
 
33
                        l("3,4,5")
 
34
                        self.fail()
 
35
                except:
 
36
                        pass
 
37
 
 
38
if __name__ == '__main__':
 
39
        suite = unittest.TestLoader().loadTestsFromTestCase(PyListModule)
 
40
        unittest.TextTestRunner(verbosity=3).run(suite)