diff options
Diffstat (limited to 'tests/utils_tests/html.py')
| -rw-r--r-- | tests/utils_tests/html.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/utils_tests/html.py b/tests/utils_tests/html.py index 62c7dac24a..c1bddf42c6 100644 --- a/tests/utils_tests/html.py +++ b/tests/utils_tests/html.py @@ -1,8 +1,12 @@ from __future__ import unicode_literals +from datetime import datetime +import os import unittest from django.utils import html +from django.utils._os import upath + class TestUtilsHtml(unittest.TestCase): @@ -73,6 +77,18 @@ class TestUtilsHtml(unittest.TestCase): for value, output in items: self.check_output(f, value, output) + # Test with more lengthy content (also catching performance regressions) + for filename in ('strip_tags1.html', 'strip_tags2.txt'): + path = os.path.join(os.path.dirname(upath(__file__)), 'files', filename) + with open(path, 'r') as fp: + start = datetime.now() + stripped = html.strip_tags(fp.read()) + elapsed = datetime.now() - start + self.assertEqual(elapsed.seconds, 0) + self.assertLess(elapsed.microseconds, 100000) + self.assertIn("Please try again.", stripped) + self.assertNotIn('<', stripped) + def test_strip_spaces_between_tags(self): f = html.strip_spaces_between_tags # Strings that should come out untouched. |
