7 class UtilsTest(unittest.TestCase):
10 self.old_template_dir = utils._template_dir
11 self.tmpdir = tempfile.mkdtemp()
12 utils._template_dir = self.tmpdir
15 os.system('rm -fr "%s"' % self.tmpdir)
16 utils._template_dir = self.old_template_dir
18 def test_render(self):
19 tf = os.path.join(utils._template_dir, 'test')
21 tfd.write('this is a %(sub)s\n')
23 of = os.path.join(self.tmpdir, 'test.out')
24 utils.render(of, 'test', {'sub':'TEST'})
25 self.assert_(os.path.exists(of))
26 output = open(of, 'r').read()
27 self.assertEquals('this is a TEST\n', output)
29 def test_parse_bool(self):
30 self.assertTrue(utils.parse_bool('y'))
31 self.assertTrue(utils.parse_bool('1'))
32 self.assertTrue(utils.parse_bool('true'))
33 self.assertFalse(utils.parse_bool('false'))
34 self.assertFalse(utils.parse_bool('no'))
37 if __name__ == '__main__':