From cd8b3b6c37027789ee6a59db64458427b4381792 Mon Sep 17 00:00:00 2001 From: Frank Loemker Date: Thu, 2 Jan 2020 23:35:09 -0500 Subject: [PATCH] Be robust against any line ending compination of \r and \n. --- tests/plugins/editsection/test_editsection.py | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/tests/plugins/editsection/test_editsection.py b/tests/plugins/editsection/test_editsection.py index 4396986e..b25488e8 100644 --- a/tests/plugins/editsection/test_editsection.py +++ b/tests/plugins/editsection/test_editsection.py @@ -36,7 +36,7 @@ class EditSectionTests(RequireRootArticleMixin, DjangoClientTestBase): 'Title 5\[edit\].*' 'Title 6\[edit\].*' ) - self.assertRegexpMatches(output, expected) + self.assertRegex(output, expected) # Test wrong header text. Editing should fail with a redirect. url = reverse('wiki:editsection', kwargs={'path': 'testedit/', 'location': '1-2-1', 'header': 'Test'}) @@ -47,23 +47,23 @@ class EditSectionTests(RequireRootArticleMixin, DjangoClientTestBase): url = reverse('wiki:editsection', kwargs={'path': 'testedit/', 'location': '1-2-1', 'header': 'T4'}) response = self.client.get(url) expected = ( - '>### Title 4\n' + '>### Title 4[\r\n]*' '<' ) - self.assertContains(response, expected) + self.assertRegex(response.rendered_content, expected) url = reverse('wiki:editsection', kwargs={'path': 'testedit/', 'location': '1-2-0', 'header': 'T3'}) response = self.client.get(url) expected = ( - '>Title 3\n' - '-------\n' - 'a\n' - 'Paragraph\n' - '-------\n' - '### Title 4\n' + '>Title 3[\r\n]*' + '-------[\r\n]*' + 'a[\r\n]*' + 'Paragraph[\r\n]*' + '-------[\r\n]*' + '### Title 4[\r\n]*' '<' ) - self.assertContains(response, expected) + self.assertRegex(response.rendered_content, expected) class EditSectionEditBase(RequireRootArticleMixin, FuncBaseMixin): @@ -91,7 +91,7 @@ class EditSectionEditTests(EditSectionEditBase, WebTestBase): 'Title 5\[edit\].*' 'Title 6\[edit\].*' ) - self.assertRegexpMatches(self.last_response.content.decode('utf-8'), expected) + self.assertRegex(self.last_response.content.decode('utf-8'), expected) new_number = URLPath.objects.get(slug='testedit').article.current_revision.revision_number self.assertEqual(new_number, old_number + 1) -- 2.45.2