diff options
| author | David Smith <39445562+smithdc1@users.noreply.github.com> | 2020-05-14 11:36:38 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-05-14 12:36:38 +0200 |
| commit | 03537e245886ed1811444c0993025dc2e08ac38b (patch) | |
| tree | f93fe33cdbf60c69a50b005f805f0a0e83031a72 /tests/template_tests/syntax_tests | |
| parent | d522b51c401429c169d88742178a9b3777903d9e (diff) | |
Completed lorem tag test coverage.
Diffstat (limited to 'tests/template_tests/syntax_tests')
| -rw-r--r-- | tests/template_tests/syntax_tests/test_lorem.py | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/tests/template_tests/syntax_tests/test_lorem.py b/tests/template_tests/syntax_tests/test_lorem.py index 631bc3d067..4c81aadc66 100644 --- a/tests/template_tests/syntax_tests/test_lorem.py +++ b/tests/template_tests/syntax_tests/test_lorem.py @@ -1,5 +1,6 @@ +from django.template.base import TemplateSyntaxError from django.test import SimpleTestCase -from django.utils.lorem_ipsum import WORDS +from django.utils.lorem_ipsum import COMMON_P, WORDS from ..utils import setup @@ -18,3 +19,24 @@ class LoremTagTests(SimpleTestCase): self.assertEqual(len(words), 3) for word in words: self.assertIn(word, WORDS) + + @setup({'lorem_default': '{% lorem %}'}) + def test_lorem_default(self): + output = self.engine.render_to_string('lorem_default') + self.assertEqual(output, COMMON_P) + + @setup({'lorem_syntax_error': '{% lorem 1 2 3 4 %}'}) + def test_lorem_syntax(self): + msg = "Incorrect format for 'lorem' tag" + with self.assertRaisesMessage(TemplateSyntaxError, msg): + self.engine.render_to_string('lorem_syntax_error') + + @setup({'lorem_multiple_paragraphs': '{% lorem 2 p %}'}) + def test_lorem_multiple_paragraphs(self): + output = self.engine.render_to_string('lorem_multiple_paragraphs') + self.assertEqual(output.count('<p>'), 2) + + @setup({'lorem_incorrect_count': '{% lorem two p %}'}) + def test_lorem_incorrect_count(self): + output = self.engine.render_to_string('lorem_incorrect_count') + self.assertEqual(output.count('<p>'), 1) |
