[PATCH 7/7] Fix Python3.6 depreciation warnings
Daniel Axtens
dja at axtens.net
Thu Jan 25 13:43:17 AEDT 2018
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 at 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(-)
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 at 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."""
--
2.14.1
More information about the Patchwork
mailing list