From 186fcb318a87e6e89add597b8dc2d8443a765bc8 Mon Sep 17 00:00:00 2001 From: Aymeric Augustin Date: Fri, 18 Oct 2013 17:01:52 +0200 Subject: Ensure the toolbar only outputs valid XML. This allows using it in websites served with the application/xml+xhtml mime type. Fix #221. --- tests/tests.py | 7 +++++++ tests/views.py | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/tests.py b/tests/tests.py index 1188ee0..9194325 100644 --- a/tests/tests.py +++ b/tests/tests.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import logging import threading +from xml.etree import ElementTree as ET import django from django.conf import settings @@ -191,6 +192,12 @@ class DebugToolbarIntegrationTestCase(TestCase): if not six.PY3: self.assertContains(response, 'là') + def test_xml_validation(self): + response = self.client.get('/regular/XML/') + with open('/tmp/blah.html', 'wb') as f: + f.write(response.content) + ET.fromstring(response.content) # shouldn't raise ParseError + class DebugToolbarNameFromObjectTest(BaseTestCase): diff --git a/tests/views.py b/tests/views.py index a903bee..8b51706 100644 --- a/tests/views.py +++ b/tests/views.py @@ -13,7 +13,7 @@ def execute_sql(request): def regular_view(request, title): - content = '