mirror of
https://github.com/django/django.git
synced 2025-10-26 07:06:08 +00:00
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user