Completed lorem tag test coverage.

This commit is contained in:
David Smith 2020-05-14 11:36:38 +01:00 committed by GitHub
parent d522b51c40
commit 03537e2458
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 23 additions and 1 deletions

View File

@ -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)