]> code.delx.au - monosys/blob - python/test_stringinterpolate.py
Virgin mobile credit checking
[monosys] / python / test_stringinterpolate.py
1 #!/usr/bin/env python
2
3 import unittest
4
5 from stringinterpolate import string_interpolate
6
7 class TestInterpolate(unittest.TestCase):
8 def test1(self):
9 format = "%(a)s %(b)s"
10 data = {"a": "hello", "b": "world"}
11 result = list(string_interpolate(format, data))
12 expected = ["hello world"]
13 self.assertEquals(result, expected)
14
15 def test2(self):
16 format = "%(a)s %(b)s"
17 data = {"a": ["hello", "hello2"], "b": ["world", "world2"]}
18 result = list(string_interpolate(format, data))
19 expected = ["hello world", "hello world2", "hello2 world", "hello2 world2"]
20 self.assertEquals(result, expected)
21
22 def test3(self):
23 format = "%(a)s %(b)s"
24 data = {"a": ["hello", "hello2"], "b": "world"}
25 result = list(string_interpolate(format, data))
26 expected = ["hello world", "hello2 world"]
27 self.assertEquals(result, expected)
28
29 if __name__ == "__main__":
30 unittest.main()
31