From 08286ca5d93c142a60edda5ee37b3a8a7bc72274 Mon Sep 17 00:00:00 2001 From: Claude Paroz Date: Mon, 15 Oct 2012 22:33:16 +0200 Subject: [PATCH] Made use of assertXMLEqual in sitemaps tests --- django/contrib/sitemaps/tests/generic.py | 2 +- django/contrib/sitemaps/tests/http.py | 14 +++++++------- django/contrib/sitemaps/tests/https.py | 8 ++++---- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/django/contrib/sitemaps/tests/generic.py b/django/contrib/sitemaps/tests/generic.py index e0b0a827a6..ae054c95c2 100644 --- a/django/contrib/sitemaps/tests/generic.py +++ b/django/contrib/sitemaps/tests/generic.py @@ -19,4 +19,4 @@ class GenericViewsSitemapTests(SitemapTestsBase): %s """ % expected - self.assertEqual(response.content, expected_content.encode('utf-8')) + self.assertXMLEqual(response.content.decode('utf-8'), expected_content) diff --git a/django/contrib/sitemaps/tests/http.py b/django/contrib/sitemaps/tests/http.py index 8da971876f..99042fef03 100644 --- a/django/contrib/sitemaps/tests/http.py +++ b/django/contrib/sitemaps/tests/http.py @@ -26,7 +26,7 @@ class HTTPSitemapTests(SitemapTestsBase): %s/simple/sitemap-simple.xml """ % self.base_url - self.assertEqual(response.content, expected_content.encode('utf-8')) + self.assertXMLEqual(response.content.decode('utf-8'), expected_content) @override_settings( TEMPLATE_DIRS=(os.path.join(os.path.dirname(__file__), 'templates'),) @@ -40,7 +40,7 @@ class HTTPSitemapTests(SitemapTestsBase): %s/simple/sitemap-simple.xml """ % self.base_url - self.assertEqual(response.content, expected_content.encode('utf-8')) + self.assertXMLEqual(response.content.decode('utf-8'), expected_content) def test_simple_sitemap_section(self): @@ -51,7 +51,7 @@ class HTTPSitemapTests(SitemapTestsBase): %s/location/%snever0.5 """ % (self.base_url, date.today()) - self.assertEqual(response.content, expected_content.encode('utf-8')) + self.assertXMLEqual(response.content.decode('utf-8'), expected_content) def test_simple_sitemap(self): "A simple sitemap can be rendered" @@ -61,7 +61,7 @@ class HTTPSitemapTests(SitemapTestsBase): %s/location/%snever0.5 """ % (self.base_url, date.today()) - self.assertEqual(response.content, expected_content.encode('utf-8')) + self.assertXMLEqual(response.content.decode('utf-8'), expected_content) @override_settings( TEMPLATE_DIRS=(os.path.join(os.path.dirname(__file__), 'templates'),) @@ -75,7 +75,7 @@ class HTTPSitemapTests(SitemapTestsBase): %s/location/%snever0.5 """ % (self.base_url, date.today()) - self.assertEqual(response.content, expected_content.encode('utf-8')) + self.assertXMLEqual(response.content.decode('utf-8'), expected_content) @skipUnless(settings.USE_I18N, "Internationalization is not enabled") @override_settings(USE_L10N=True) @@ -101,7 +101,7 @@ class HTTPSitemapTests(SitemapTestsBase): http://testserver/location/%snever0.5 """ % date.today() - self.assertEqual(response.content, expected_content.encode('utf-8')) + self.assertXMLEqual(response.content.decode('utf-8'), expected_content) @skipUnless("django.contrib.sites" in settings.INSTALLED_APPS, "django.contrib.sites app not installed.") @@ -143,4 +143,4 @@ class HTTPSitemapTests(SitemapTestsBase): %s/cached/sitemap-simple.xml """ % self.base_url - self.assertEqual(response.content, expected_content.encode('utf-8')) + self.assertXMLEqual(response.content.decode('utf-8'), expected_content) diff --git a/django/contrib/sitemaps/tests/https.py b/django/contrib/sitemaps/tests/https.py index 26241eb30b..baad02ac07 100644 --- a/django/contrib/sitemaps/tests/https.py +++ b/django/contrib/sitemaps/tests/https.py @@ -18,7 +18,7 @@ class HTTPSSitemapTests(SitemapTestsBase): %s/secure/sitemap-simple.xml """ % self.base_url - self.assertEqual(response.content, expected_content.encode('utf-8')) + self.assertXMLEqual(response.content.decode('utf-8'), expected_content) def test_secure_sitemap_section(self): "A secure sitemap section can be rendered" @@ -28,7 +28,7 @@ class HTTPSSitemapTests(SitemapTestsBase): %s/location/%snever0.5 """ % (self.base_url, date.today()) - self.assertEqual(response.content, expected_content.encode('utf-8')) + self.assertXMLEqual(response.content.decode('utf-8'), expected_content) @override_settings(SECURE_PROXY_SSL_HEADER=False) @@ -43,7 +43,7 @@ class HTTPSDetectionSitemapTests(SitemapTestsBase): %s/simple/sitemap-simple.xml """ % self.base_url.replace('http://', 'https://') - self.assertEqual(response.content, expected_content.encode('utf-8')) + self.assertXMLEqual(response.content.decode('utf-8'), expected_content) def test_sitemap_section_with_https_request(self): "A sitemap section requested in HTTPS is rendered with HTTPS links" @@ -53,4 +53,4 @@ class HTTPSDetectionSitemapTests(SitemapTestsBase): %s/location/%snever0.5 """ % (self.base_url.replace('http://', 'https://'), date.today()) - self.assertEqual(response.content, expected_content.encode('utf-8')) + self.assertXMLEqual(response.content.decode('utf-8'), expected_content)