# Create your tests here.
from .models import Tag, Author, Work, Quote
import re
+import lxml.etree
class QuoteTest(TestCase):
def setUp(self):
response = c.get('/quotes/' + url)
self.assertEqual(response.status_code, 200)
self.assertEqual(response.charset, 'utf-8')
- return response.content.decode(response.charset)
+ document = response.content.decode(response.charset)
+ try:
+ lxml.etree.fromstring(document)
+ except lxml.etree.XMLSyntaxError as e:
+ self.assertTrue(False, 'Errors in page at %s: %s' % (url, e))
+ return document
def setUp(self):
a1 = Author.objects.create(name="Author with notes",
# <a href="{% url 'quotes:onequote' quote.id %}">Permalink</a>
permalinkre = re.compile(r'([0-9]+).*Permalink')
- for i in xrange(100):
+ for i in range(100):
content = self.getPage('random')
m = permalinkre.search(content)
self.assertIsNotNone(m, content)