Permalink
Browse files

- Add test for haml_tags

  • Loading branch information...
1 parent eb6cead commit 9d26238229979f4224b5603c97c277002ef60d30 @Naddiseo Naddiseo committed Dec 9, 2011
Showing with 51 additions and 1 deletion.
  1. +2 −1 tests/alltests.py
  2. +49 −0 tests/test_haml_tags.py
View
@@ -8,7 +8,8 @@
tests = [
'test_debug_output', 'test_html_tags', 'test_jinja_tags',
- 'test_syntax', 'test_div_shortcut', 'test_compact_output'
+ 'test_syntax', 'test_div_shortcut', 'test_compact_output',
+ 'test_haml_tags'
]
suite = unittest.TestLoader().loadTestsFromNames(tests)
View
@@ -0,0 +1,49 @@
+# -*- coding: utf-8 -*-
+
+import unittest
+import jinja2
+from hamlish_jinja import Hamlish, Output, HamlishTagExtension
+
+import testing_base
+
+
+jinja_env = jinja2.Environment(
+ extensions = [
+ HamlishTagExtension,
+ ]
+)
+
+class TestHamlTags(testing_base.TestCase):
+
+ def setUp(self):
+ self.hamlish = Hamlish(
+ Output(indent_string='', newline_string='', debug=False))
+
+
+ def test_basic(self):
+ s = jinja_env.from_string(
+'''{% haml %}
+%div
+ %p
+ test
+{% endhaml %}
+''')
+ r = u'''<div><p>test</p></div>'''
+ self.assertEqual(s.render(),r)
+
+ def test_multiple(self):
+ s = jinja_env.from_string(
+'''{% haml %}
+%div
+ %p
+ test
+{% endhaml %}
+<div>hello</div>
+{% haml %}
+%div
+ %p
+ test
+{% endhaml %}
+''')
+ r = u'''<div><p>test</p></div>\n<div>hello</div>\n<div><p>test</p></div>'''
+ self.assertEqual(s.render(),r)

0 comments on commit 9d26238

Please sign in to comment.