diff mbox series

[7/7] Fix Python3.6 depreciation warnings

Message ID 20180125024317.14709-8-dja@axtens.net
State Accepted
Headers show
Series Various fixes | expand

Commit Message

Daniel Axtens Jan. 25, 2018, 2:43 a.m. UTC
We see on Travis and on tox:
/home/travis/build/daxtens/patchwork/patchwork/tests/test_list.py:79: DeprecationWarning: invalid escape sequence \d
  id_re = re.compile('<tr id="patch_row:(\d+)"')
/home/travis/build/daxtens/patchwork/patchwork/tests/test_mail_settings.py:248: DeprecationWarning: invalid escape sequence \s
  form_re_template = ('<form\s+[^>]*action="%(url)s"[^>]*>'
/home/travis/build/daxtens/patchwork/patchwork/tests/test_parser.py:616: DeprecationWarning: invalid escape sequence \
  '\ No newline at end of file'))

All of these are easy to fix: just mark them as raw strings.

Signed-off-by: Daniel Axtens <dja@axtens.net>
---
 patchwork/tests/test_list.py          | 2 +-
 patchwork/tests/test_mail_settings.py | 6 +++---
 patchwork/tests/test_parser.py        | 6 +++---
 3 files changed, 7 insertions(+), 7 deletions(-)

Comments

Stephen Finucane Jan. 26, 2018, 9:23 p.m. UTC | #1
On Thu, 2018-01-25 at 13:43 +1100, Daniel Axtens wrote:
> We see on Travis and on tox:
> /home/travis/build/daxtens/patchwork/patchwork/tests/test_list.py:79:
> DeprecationWarning: invalid escape sequence \d
>   id_re = re.compile('<tr id="patch_row:(\d+)"')
> /home/travis/build/daxtens/patchwork/patchwork/tests/test_mail_settin
> gs.py:248: DeprecationWarning: invalid escape sequence \s
>   form_re_template = ('<form\s+[^>]*action="%(url)s"[^>]*>'
> /home/travis/build/daxtens/patchwork/patchwork/tests/test_parser.py:6
> 16: DeprecationWarning: invalid escape sequence \
>   '\ No newline at end of file'))
> 
> All of these are easy to fix: just mark them as raw strings.
> 
> Signed-off-by: Daniel Axtens <dja@axtens.net>

Reviewed-by: Stephen Finucane <stephen@that.guru>
diff mbox series

Patch

diff --git a/patchwork/tests/test_list.py b/patchwork/tests/test_list.py
index 11b9da9c11d3..2a023ac6d7f1 100644
--- a/patchwork/tests/test_list.py
+++ b/patchwork/tests/test_list.py
@@ -76,7 +76,7 @@  class PatchOrderTest(TestCase):
                          date=date)
 
     def _extract_patch_ids(self, response):
-        id_re = re.compile('<tr id="patch_row:(\d+)"')
+        id_re = re.compile(r'<tr id="patch_row:(\d+)"')
         ids = [int(m.group(1))
                for m in id_re.finditer(response.content.decode())]
 
diff --git a/patchwork/tests/test_mail_settings.py b/patchwork/tests/test_mail_settings.py
index 1eb497534404..d38149d86425 100644
--- a/patchwork/tests/test_mail_settings.py
+++ b/patchwork/tests/test_mail_settings.py
@@ -245,9 +245,9 @@  class UserProfileOptoutFormTest(TestCase):
 
     """Validate presence of correct optin/optout forms."""
 
-    form_re_template = ('<form\s+[^>]*action="%(url)s"[^>]*>'
-                        '.*?<input\s+[^>]*value="%(email)s"[^>]*>.*?'
-                        '</form>')
+    form_re_template = (r'<form\s+[^>]*action="%(url)s"[^>]*>'
+                        r'.*?<input\s+[^>]*value="%(email)s"[^>]*>.*?'
+                        r'</form>')
 
     def setUp(self):
         self.secondary_email = 'test2@example.com'
diff --git a/patchwork/tests/test_parser.py b/patchwork/tests/test_parser.py
index 42f96fe7fc79..fbc85993d899 100644
--- a/patchwork/tests/test_parser.py
+++ b/patchwork/tests/test_parser.py
@@ -613,12 +613,12 @@  class PatchParseTest(PatchTest):
             'diff --git a/tools/testing/selftests/powerpc/Makefile'))
         # Confirm the trailing no newline marker doesn't end up in the comment
         self.assertFalse(message.rstrip().endswith(
-            '\ No newline at end of file'))
+            r'\ No newline at end of file'))
         # Confirm it's instead at the bottom of the patch
         self.assertTrue(diff.rstrip().endswith(
-            '\ No newline at end of file'))
+            r'\ No newline at end of file'))
         # Confirm we got both markers
-        self.assertEqual(2, diff.count('\ No newline at end of file'))
+        self.assertEqual(2, diff.count(r'\ No newline at end of file'))
 
     def test_no_subject(self):
         """Validate parsing a mail with no subject."""