From 3661a670aa9e6224383bc1ab9612987887494df5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Fr=C3=A9d=C3=A9ric=20Perrin?= Date: Tue, 18 Oct 2016 23:52:35 +0100 Subject: [PATCH] Validate all pages in tests --- quotes/tests.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/quotes/tests.py b/quotes/tests.py index 66ff00b..2d75e32 100644 --- a/quotes/tests.py +++ b/quotes/tests.py @@ -3,6 +3,7 @@ from django.test import TestCase, Client # Create your tests here. from .models import Tag, Author, Work, Quote import re +import lxml.etree class QuoteTest(TestCase): def setUp(self): @@ -24,7 +25,12 @@ class ViewsTest(TestCase): 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", @@ -64,7 +70,7 @@ class ViewsTest(TestCase): # Permalink 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) -- 2.43.0