diff options
author | Andrew Donnellan <ajd@linux.ibm.com> | 2020-04-08 22:52:26 +0100 |
---|---|---|
committer | Stephen Finucane <stephen@that.guru> | 2020-04-08 23:35:02 +0100 |
commit | e2471e523149d582c25a842947cf58fa6fd88703 (patch) | |
tree | 5327fac30c5589a57eb6df1e420bb5f8da78ef20 | |
parent | 801106e3333ec0b29a490c1442f5e85d5465f345 (diff) | |
download | patchwork-e2471e523149d582c25a842947cf58fa6fd88703.tar patchwork-e2471e523149d582c25a842947cf58fa6fd88703.tar.gz |
tests: Fix escaping in bundle tests on Django 3.0
Django 3.0 switches to using Python 3's built-in HTML escaper, which
prefers to escape entities using hex rather than decimal.
Some of our tests check rendered HTML output against pre-escaped
strings, and fail because ''' is now '''.
Fix this by using the escape function so we get consistent escaping no
matter which Django version.
Signed-off-by: Andrew Donnellan <ajd@linux.ibm.com>
Reviewed-by: Stephen Finucane <stephen@that.guru>
-rw-r--r-- | patchwork/tests/test_bundles.py | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/patchwork/tests/test_bundles.py b/patchwork/tests/test_bundles.py index 63f943c..6a74409 100644 --- a/patchwork/tests/test_bundles.py +++ b/patchwork/tests/test_bundles.py @@ -10,6 +10,7 @@ import unittest from django.conf import settings from django.test import TestCase from django.urls import reverse +from django.utils.html import escape from django.utils.http import urlencode from patchwork.models import Bundle @@ -548,8 +549,8 @@ class BundleAddFromListTest(BundleTestBase): 'project_id': self.project.linkname}), params) - self.assertContains(response, 'Patch '%s' already in bundle' - % patch.name, count=1, status_code=200) + expected = escape(f"Patch '{patch.name}' already in bundle") + self.assertContains(response, expected, count=1, status_code=200) self.assertEqual(count, self.bundle.patches.count()) @@ -570,11 +571,12 @@ class BundleAddFromListTest(BundleTestBase): 'project_id': self.project.linkname}), params) - self.assertContains(response, 'Patch '%s' already in bundle' - % patch.name, count=1, status_code=200) - self.assertContains(response, 'Patch '%s' added to bundle' - % self.patches[1].name, count=1, - status_code=200) + for expected in ( + escape(f"Patch '{patch.name}' already in bundle"), + escape(f"Patch '{self.patches[1].name}' added to bundle"), + ): + self.assertContains(response, expected, count=1, status_code=200) + self.assertEqual(count + 1, self.bundle.patches.count()) |