← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~cjwatson/launchpad:py3-code-raw-strings into launchpad:master

 

Colin Watson has proposed merging ~cjwatson/launchpad:py3-code-raw-strings into launchpad:master.

Commit message:
Correct spelling of \-escapes in lp.code

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/392146

Use raw strings or double-\, depending on whether it's more convenient for '\n' to mean a newline character or the two characters '\' 'n'.  This fixes a number of DeprecationWarnings with Python >= 3.6.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:py3-code-raw-strings into launchpad:master.
diff --git a/lib/lp/code/browser/tests/test_branch.py b/lib/lp/code/browser/tests/test_branch.py
index 4c9f473..7a58689 100644
--- a/lib/lp/code/browser/tests/test_branch.py
+++ b/lib/lp/code/browser/tests/test_branch.py
@@ -441,7 +441,7 @@ class TestBranchView(BrowserTestCase):
             1. By Eric the Viking <eric@xxxxxxxxxxxxxxxxxxxxxxxx>
             .*
             Testing the email address in revisions\n
-            email Bob \(bob@xxxxxxxxxxx\) for details.
+            email Bob \\(bob@xxxxxxxxxxx\\) for details.
             """
 
         self.assertTextMatchesExpressionIgnoreWhitespace(expected_text, text)
@@ -464,7 +464,7 @@ class TestBranchView(BrowserTestCase):
             1. By Eric the Viking <email address hidden>
             .*
             Testing the email address in revisions\n
-            email Bob \(<email address hidden>\) for details.
+            email Bob \\(<email address hidden>\\) for details.
             """
         self.assertTextMatchesExpressionIgnoreWhitespace(expected_text, text)
 
@@ -495,11 +495,11 @@ class TestBranchView(BrowserTestCase):
             2. By Eric the Viking <eric@xxxxxxxxxxxxxxxxxxxxxxxx>
             .*
             Testing the email address in revisions\n
-            email Bob \(bob@xxxxxxxxxxx\) for details.\n
+            email Bob \\(bob@xxxxxxxxxxx\\) for details.\n
             1. By Eric the Viking <eric@xxxxxxxxxxxxxxxxxxxxxxxx>
             .*
             Testing the email address in revisions\n
-            email Bob \(bob@xxxxxxxxxxx\) for details.
+            email Bob \\(bob@xxxxxxxxxxx\\) for details.
             Merged branch %s
             """ % branch_display_name
 
@@ -549,11 +549,11 @@ class TestBranchView(BrowserTestCase):
             2. By Eric the Viking <eric@xxxxxxxxxxxxxxxxxxxxxxxx>
             .*
             Testing the email address in revisions\n
-            email Bob \(bob@xxxxxxxxxxx\) for details.\n
+            email Bob \\(bob@xxxxxxxxxxx\\) for details.\n
             1. By Eric the Viking <eric@xxxxxxxxxxxxxxxxxxxxxxxx>
             .*
             Testing the email address in revisions\n
-            email Bob \(bob@xxxxxxxxxxx\) for details.
+            email Bob \\(bob@xxxxxxxxxxx\\) for details.
             Merged branch %s
             %s
             """ % (branch_display_name, linked_bug_rendered_text)
diff --git a/lib/lp/code/browser/tests/test_branchmergeproposal.py b/lib/lp/code/browser/tests/test_branchmergeproposal.py
index ed729c2..f2ec4ec 100644
--- a/lib/lp/code/browser/tests/test_branchmergeproposal.py
+++ b/lib/lp/code/browser/tests/test_branchmergeproposal.py
@@ -1704,7 +1704,7 @@ class TestBranchMergeProposalView(TestCaseWithFactory):
                     Tag(
                         'merge proposal breadcrumb', 'li',
                         text=re.compile(
-                            '\sMerge into %s\s' %
+                            r'\sMerge into %s\s' %
                             re.escape(bmp.target_branch.name))))))
 
     def test_breadcrumbs_git(self):
@@ -1746,7 +1746,7 @@ class TestBranchMergeProposalView(TestCaseWithFactory):
                     Tag(
                         'merge proposal breadcrumb', 'li',
                         text=re.compile(
-                            '\sMerge into %s\s' %
+                            r'\sMerge into %s\s' %
                             re.escape(bmp.target_git_ref.name))))))
 
 
diff --git a/lib/lp/code/browser/tests/test_codeimport.py b/lib/lp/code/browser/tests/test_codeimport.py
index 68b8b2e..a54a500 100644
--- a/lib/lp/code/browser/tests/test_codeimport.py
+++ b/lib/lp/code/browser/tests/test_codeimport.py
@@ -50,7 +50,7 @@ class TestImportDetails(TestCaseWithFactory):
         details = find_tag_by_id(browser.contents, details_id)
         if span_title is not None:
             self.assertEqual(span_title, details.span['title'])
-        text = re.sub('\s+', ' ', extract_text(details))
+        text = re.sub(r'\s+', ' ', extract_text(details))
         self.assertThat(text, StartsWith(prefix_text))
 
     def test_bzr_svn_import(self):
diff --git a/lib/lp/code/browser/tests/test_sourcepackagerecipe.py b/lib/lp/code/browser/tests/test_sourcepackagerecipe.py
index 3b1124a..6352f30 100644
--- a/lib/lp/code/browser/tests/test_sourcepackagerecipe.py
+++ b/lib/lp/code/browser/tests/test_sourcepackagerecipe.py
@@ -1209,7 +1209,7 @@ class TestSourcePackageRecipeViewMixin:
 
     def test_index(self):
         build = self.makeSuccessfulBuild()
-        self.assertTextMatchesExpressionIgnoreWhitespace("""\
+        self.assertTextMatchesExpressionIgnoreWhitespace(r"""
             Recipes cake_recipe
             .*
             Description Edit
@@ -1237,7 +1237,7 @@ class TestSourcePackageRecipeViewMixin:
         build = self.makeSuccessfulBuild()
         build.setLog(self.factory.makeLibraryFileAlias())
 
-        self.assertTextMatchesExpressionIgnoreWhitespace("""\
+        self.assertTextMatchesExpressionIgnoreWhitespace(r"""
             Latest builds
             Status .* Archive
             Successful build on 2010-03-16 buildlog \(.*\)
@@ -1263,7 +1263,7 @@ class TestSourcePackageRecipeViewMixin:
             processor=builder.processor)
         binary_build.queueBuild()
 
-        self.assertTextMatchesExpressionIgnoreWhitespace("""\
+        self.assertTextMatchesExpressionIgnoreWhitespace(r"""
             Latest builds
             Status .* Archive
             Successful build on 2010-03-16 buildlog \(.*\)
@@ -1297,7 +1297,7 @@ class TestSourcePackageRecipeViewMixin:
             date_finished=datetime(2010, 4, 16, tzinfo=UTC))
         binary_build.setLog(self.factory.makeLibraryFileAlias())
 
-        self.assertTextMatchesExpressionIgnoreWhitespace("""\
+        self.assertTextMatchesExpressionIgnoreWhitespace(r"""
             Latest builds
             Status .* Archive
             Successful build on 2010-03-16 buildlog \(.*\) Secret Squirrel
@@ -1316,7 +1316,7 @@ class TestSourcePackageRecipeViewMixin:
     def test_index_no_builds(self):
         """A message should be shown when there are no builds."""
         recipe = self.makeRecipe()
-        self.assertTextMatchesExpressionIgnoreWhitespace("""\
+        self.assertTextMatchesExpressionIgnoreWhitespace(r"""
             Latest builds
             Status .* Archive
             This recipe has not been built yet.""", self.getMainText(recipe))
@@ -1325,7 +1325,7 @@ class TestSourcePackageRecipeViewMixin:
         recipe = self.makeRecipe()
         self.factory.makeSourcePackageRecipeBuild(
             recipe=recipe, distroseries=self.squirrel, archive=self.ppa)
-        self.assertTextMatchesExpressionIgnoreWhitespace("""
+        self.assertTextMatchesExpressionIgnoreWhitespace(r"""
             Latest builds
             Status .* Archive
             No suitable builders Secret Squirrel Secret PPA
@@ -1344,7 +1344,7 @@ class TestSourcePackageRecipeViewMixin:
         recipe = self.makeRecipe()
         self.makeBuildJob(recipe)
         self.factory.makeBuilder()
-        pattern = """\
+        pattern = r"""
             Latest builds
             Status .* Archive
             Pending build in .* \(estimated\) Secret Squirrel Secret PPA
@@ -1780,11 +1780,11 @@ class TestSourcePackageRecipeBuildViewMixin:
     def test_render_index(self):
         """Test the basic index page."""
         main_text = self.getMainText(self.makeBuild(), '+index')
-        self.assertTextMatchesExpressionIgnoreWhitespace("""\
+        self.assertTextMatchesExpressionIgnoreWhitespace(r"""
             created .*
             Build status
             Needs building
-            Start in .* \\(2510\\) What's this?.*
+            Start in .* \(2510\) What's this?.*
             Estimated finish in .*
             Build details
             Recipe:        Recipe my-recipe for Owner
@@ -1809,7 +1809,7 @@ class TestSourcePackageRecipeBuildViewMixin:
         build.storeUploadLog('upload_log')
         main_text = self.getMainText(
             release.source_package_recipe_build, '+index')
-        self.assertTextMatchesExpressionIgnoreWhitespace("""\
+        self.assertTextMatchesExpressionIgnoreWhitespace(r"""
             created .*
             Build status
             Successfully built
@@ -1851,7 +1851,7 @@ class TestSourcePackageRecipeBuildViewMixin:
         self.makeBinaryBuild(release, 'x87-64')
         main_text = self.getMainText(
             release.source_package_recipe_build, '+index')
-        self.assertTextMatchesExpressionIgnoreWhitespace("""\
+        self.assertTextMatchesExpressionIgnoreWhitespace(r"""
             Binary builds:
             itanic build of .* 3.14 in ubuntu squirrel RELEASE
             x87-64 build of .* 3.14 in ubuntu squirrel RELEASE$""",
diff --git a/lib/lp/code/scripts/tests/test_merge_proposal_jobs.py b/lib/lp/code/scripts/tests/test_merge_proposal_jobs.py
index ec2ffa9..df1d6ff 100644
--- a/lib/lp/code/scripts/tests/test_merge_proposal_jobs.py
+++ b/lib/lp/code/scripts/tests/test_merge_proposal_jobs.py
@@ -31,23 +31,23 @@ class TestMergeProposalJobScript(DiffTestCase):
         self.assertEqual(0, retcode)
         self.assertEqual('', stdout)
         matches_expected = MatchesRegex(
-            'INFO    Creating lockfile: /var/lock/launchpad-process-job-'
-            'source-IBranchMergeProposalJobSource.lock\n'
-            'INFO    Running through Twisted.\n'
-            'Log opened.\n'
-            'INFO    Log opened.\n'
-            'ProcessPool stats:\n'
-            '    workers:       0\n'
-            '(.|\n)*'
-            'INFO    ProcessPool stats:\n'
-            '    workers:       0\n'
-            '(.|\n)*'
-            'INFO    Running '
-            '<GENERATE_INCREMENTAL_DIFF job for merge .*?> \(ID %d\).\n'
-            '(.|\n)*'
-            'INFO    STOPPING: \n'
-            'Main loop terminated.\n'
-            'INFO    Main loop terminated.\n'
-            'INFO    Ran 1 GenerateIncrementalDiffJob jobs.\n' % job.job.id)
+            r'INFO    Creating lockfile: /var/lock/launchpad-process-job-'
+            r'source-IBranchMergeProposalJobSource.lock\n'
+            r'INFO    Running through Twisted.\n'
+            r'Log opened.\n'
+            r'INFO    Log opened.\n'
+            r'ProcessPool stats:\n'
+            r'    workers:       0\n'
+            r'(.|\n)*'
+            r'INFO    ProcessPool stats:\n'
+            r'    workers:       0\n'
+            r'(.|\n)*'
+            r'INFO    Running '
+            r'<GENERATE_INCREMENTAL_DIFF job for merge .*?> \(ID %d\).\n'
+            r'(.|\n)*'
+            r'INFO    STOPPING: \n'
+            r'Main loop terminated.\n'
+            r'INFO    Main loop terminated.\n'
+            r'INFO    Ran 1 GenerateIncrementalDiffJob jobs.\n' % job.job.id)
         self.assertThat(stderr, matches_expected)
         self.assertEqual(JobStatus.COMPLETED, job.status)
diff --git a/lib/lp/code/scripts/tests/test_reclaim_branch_space.py b/lib/lp/code/scripts/tests/test_reclaim_branch_space.py
index e1ce685..b9e18d7 100644
--- a/lib/lp/code/scripts/tests/test_reclaim_branch_space.py
+++ b/lib/lp/code/scripts/tests/test_reclaim_branch_space.py
@@ -63,9 +63,10 @@ class TestReclaimBranchSpaceScript(TestCaseWithFactory):
             'INFO    Creating lockfile: /var/lock/'
             'launchpad-process-job-source-IReclaimBranchSpaceJobSource.lock\n'
             'INFO    Running synchronously.\n'
-            'INFO    Running <RECLAIM_BRANCH_SPACE branch job \(\d+\) for '
-            '\d+> \(ID %s\) in status Waiting\n'
-            'INFO    Ran 1 ReclaimBranchSpaceJob jobs.\n' % reclaim_job.job.id,
+            'INFO    Running <RECLAIM_BRANCH_SPACE branch job \\(\\d+\\) for '
+            '\\d+> \\(ID %s\\) in status Waiting\n'
+            'INFO    Ran 1 ReclaimBranchSpaceJob jobs.\n' %
+            reclaim_job.job.id,
             stderr)
         self.assertEqual(0, retcode)
         self.assertFalse(
diff --git a/lib/lp/code/scripts/tests/test_sendbranchmail.py b/lib/lp/code/scripts/tests/test_sendbranchmail.py
index e7e983d..30cecae 100644
--- a/lib/lp/code/scripts/tests/test_sendbranchmail.py
+++ b/lib/lp/code/scripts/tests/test_sendbranchmail.py
@@ -55,8 +55,8 @@ class TestSendbranchmail(TestCaseWithFactory):
             'Creating lockfile: /var/lock/launchpad-process-job-source-'
             'IRevisionMailJobSource.lock\n'
             'INFO    Running synchronously.\n'
-            'INFO    Running <REVISION_MAIL branch job \(\d+\) for .*?> '
-            '\(ID %d\) in status Waiting\n'
+            'INFO    Running <REVISION_MAIL branch job \\(\\d+\\) for .*?> '
+            '\\(ID %d\\) in status Waiting\n'
             'INFO    Ran 1 RevisionMailJob jobs.\n' % mail_job.job.id, stderr)
         self.assertEqual('', stdout)
         self.assertEqual(0, retcode)
@@ -80,8 +80,8 @@ class TestSendbranchmail(TestCaseWithFactory):
             'Creating lockfile: /var/lock/launchpad-process-job-source-'
             'IRevisionsAddedJobSource.lock\n'
             'INFO    Running synchronously.\n'
-            'INFO    Running <REVISIONS_ADDED_MAIL branch job \(\d+\) '
-            'for .*?> \(ID %d\) in status Waiting\n'
+            'INFO    Running <REVISIONS_ADDED_MAIL branch job \\(\\d+\\) '
+            'for .*?> \\(ID %d\\) in status Waiting\n'
             'INFO    Ran 1 RevisionsAddedJob jobs.\n' % job.job.id,
             stderr)
         self.assertEqual('', stdout)