test_render.py 862 B

1234567891011121314151617181920212223242526
  1. import unittest
  2. import makesite
  3. class RenderTest(unittest.TestCase):
  4. """Tests for render() function."""
  5. def test_oneline_template(self):
  6. tpl = 'foo {{ key1 }} baz {{ key2 }}'
  7. out = makesite.render(tpl, key1='bar', key2='qux')
  8. self.assertEqual(out, 'foo bar baz qux')
  9. def test_multiline_template(self):
  10. tpl = 'foo {{ key1 }}\nbaz {{ key1 }}'
  11. out = makesite.render(tpl, key1='bar')
  12. self.assertEqual(out, 'foo bar\nbaz bar')
  13. def test_repeated_key(self):
  14. tpl = 'foo {{ key1 }} baz {{ key1 }}'
  15. out = makesite.render(tpl, key1='bar')
  16. self.assertEqual(out, 'foo bar baz bar')
  17. def test_multiline_placeholder(self):
  18. tpl = 'foo {{\nkey1\n}} baz {{\nkey2\n}}'
  19. out = makesite.render(tpl, key1='bar', key2='qux')
  20. self.assertEqual(out, 'foo bar baz qux')