changeset 8021:082780404e6c

cleanup: fix incorrect backslash escaping - mainly in regexps
author Mads Kiilerich <mads@kiilerich.com>
date Mon, 16 Dec 2019 02:29:34 +0100
parents 18d146a04fde
children 5b6174420e30
files kallithea/tests/api/api_base.py kallithea/tests/functional/test_changeset_pullrequests_comments.py kallithea/tests/functional/test_pullrequests.py kallithea/tests/other/test_libs.py kallithea/tests/scripts/manual_test_crawler.py kallithea/tests/vcs/test_repository.py
diffstat 6 files changed, 35 insertions(+), 35 deletions(-) [+]
line wrap: on
line diff
--- a/kallithea/tests/api/api_base.py	Mon Nov 11 00:38:52 2019 +0100
+++ b/kallithea/tests/api/api_base.py	Mon Dec 16 02:29:34 2019 +0100
@@ -2509,7 +2509,7 @@
             "revisions": self.TEST_PR_REVISIONS,
         }
         self._compare_ok(random_id, expected,
-                         given=re.sub("\d\d\d\d\-\d\d\-\d\dT\d\d\:\d\d\:\d\d",
+                         given=re.sub(r"\d\d\d\d\-\d\d\-\d\dT\d\d\:\d\d\:\d\d",
                                       "2000-01-01T00:00:00", response.body))
 
     def test_api_close_pullrequest(self):
--- a/kallithea/tests/functional/test_changeset_pullrequests_comments.py	Mon Nov 11 00:38:52 2019 +0100
+++ b/kallithea/tests/functional/test_changeset_pullrequests_comments.py	Mon Dec 16 02:29:34 2019 +0100
@@ -168,7 +168,7 @@
                                   '_session_csrf_secret_token': self.session_csrf_secret_token(),
                                  },
                                  status=302)
-        pr_id = int(re.search('/pull-request/(\d+)/', response.location).group(1))
+        pr_id = int(re.search(r'/pull-request/(\d+)/', response.location).group(1))
         return pr_id
 
     def test_create(self):
--- a/kallithea/tests/functional/test_pullrequests.py	Mon Nov 11 00:38:52 2019 +0100
+++ b/kallithea/tests/functional/test_pullrequests.py	Mon Dec 16 02:29:34 2019 +0100
@@ -94,7 +94,7 @@
                                   '_session_csrf_secret_token': self.session_csrf_secret_token(),
                                  },
                                  status=302)
-        pull_request1_id = re.search('/pull-request/(\d+)/', response.location).group(1)
+        pull_request1_id = re.search(r'/pull-request/(\d+)/', response.location).group(1)
         assert response.location == 'http://localhost/%s/pull-request/%s/_/stable' % (HG_REPO, pull_request1_id)
 
         # create new iteration
@@ -109,7 +109,7 @@
                                   'review_members': [regular_user.user_id],
                                  },
                                  status=302)
-        pull_request2_id = re.search('/pull-request/(\d+)/', response.location).group(1)
+        pull_request2_id = re.search(r'/pull-request/(\d+)/', response.location).group(1)
         assert pull_request2_id != pull_request1_id
         assert response.location == 'http://localhost/%s/pull-request/%s/_/stable' % (HG_REPO, pull_request2_id)
         response = response.follow()
@@ -155,7 +155,7 @@
                                 status=302)
         # location is of the form:
         # http://localhost/vcs_test_hg/pull-request/54/_/title
-        m = re.search('/pull-request/(\d+)/', response.location)
+        m = re.search(r'/pull-request/(\d+)/', response.location)
         assert m is not None
         pull_request_id = m.group(1)
 
@@ -191,7 +191,7 @@
                                 status=302)
         # location is of the form:
         # http://localhost/vcs_test_hg/pull-request/54/_/title
-        m = re.search('/pull-request/(\d+)/', response.location)
+        m = re.search(r'/pull-request/(\d+)/', response.location)
         assert m is not None
         pull_request_id = m.group(1)
 
@@ -237,7 +237,7 @@
                 '_session_csrf_secret_token': self.session_csrf_secret_token(),
             },
             status=302)
-        pr1_id = int(re.search('/pull-request/(\d+)/', response.location).group(1))
+        pr1_id = int(re.search(r'/pull-request/(\d+)/', response.location).group(1))
         pr1 = PullRequest.get(pr1_id)
 
         assert pr1.org_ref == 'branch:webvcs:9e6119747791ff886a5abe1193a730b6bf874e1c'
@@ -256,7 +256,7 @@
                 '_session_csrf_secret_token': self.session_csrf_secret_token(),
              },
              status=302)
-        pr2_id = int(re.search('/pull-request/(\d+)/', response.location).group(1))
+        pr2_id = int(re.search(r'/pull-request/(\d+)/', response.location).group(1))
         pr1 = PullRequest.get(pr1_id)
         pr2 = PullRequest.get(pr2_id)
 
@@ -278,7 +278,7 @@
                 '_session_csrf_secret_token': self.session_csrf_secret_token(),
              },
              status=302)
-        pr3_id = int(re.search('/pull-request/(\d+)/', response.location).group(1))
+        pr3_id = int(re.search(r'/pull-request/(\d+)/', response.location).group(1))
         pr2 = PullRequest.get(pr2_id)
         pr3 = PullRequest.get(pr3_id)
 
--- a/kallithea/tests/other/test_libs.py	Mon Nov 11 00:38:52 2019 +0100
+++ b/kallithea/tests/other/test_libs.py	Mon Dec 16 02:29:34 2019 +0100
@@ -482,7 +482,7 @@
             """empty issue_sub <a class="issue-tracker-link" href="http://foo/repo_name/issue/123">$123</a> and """
             """issue$456"""),
         # named groups
-        (r'(PR|pullrequest|pull request) ?(?P<sitecode>BRU|CPH|BER)-(?P<id>\d+)', 'http://foo/\g<sitecode>/pullrequest/\g<id>/', 'PR-\g<sitecode>-\g<id>',
+        (r'(PR|pullrequest|pull request) ?(?P<sitecode>BRU|CPH|BER)-(?P<id>\d+)', r'http://foo/\g<sitecode>/pullrequest/\g<id>/', r'PR-\g<sitecode>-\g<id>',
             'pullrequest CPH-789 is similar to PRBRU-747',
             """<a class="issue-tracker-link" href="http://foo/CPH/pullrequest/789/">PR-CPH-789</a> is similar to """
             """<a class="issue-tracker-link" href="http://foo/BRU/pullrequest/747/">PR-BRU-747</a>"""),
@@ -512,21 +512,21 @@
     def test_urlify_issues_multiple_issue_patterns(self, sample, expected):
         from kallithea.lib.helpers import urlify_text
         config_stub = {
-            'sqlalchemy.url': 'foo',
-            'issue_pat': 'X(\d+)',
-            'issue_server_link': 'http://main/{repo}/main/\\1/',
-            'issue_sub': '#\\1',
-            'issue_pat_pr': '(?:pullrequest|pull request|PR|pr) ?#?(\d+)',
-            'issue_server_link_pr': 'http://pr/{repo}/pr/\\1',
-            'issue_sub_pr': 'PR#\\1',
-            'issue_pat_bug': '(?:BUG|bug|issue) ?#?(\d+)',
-            'issue_server_link_bug': 'http://bug/{repo}/bug/\\1',
-            'issue_sub_bug': 'bug#\\1',
-            'issue_pat_empty_prefix': 'FAIL(\d+)',
-            'issue_server_link_empty_prefix': 'http://fail/{repo}/\\1',
-            'issue_sub_empty_prefix': '',
-            'issue_pat_absent_prefix': 'FAILMORE(\d+)',
-            'issue_server_link_absent_prefix': 'http://failmore/{repo}/\\1',
+            'sqlalchemy.url': r'foo',
+            'issue_pat': r'X(\d+)',
+            'issue_server_link': r'http://main/{repo}/main/\1/',
+            'issue_sub': r'#\1',
+            'issue_pat_pr': r'(?:pullrequest|pull request|PR|pr) ?#?(\d+)',
+            'issue_server_link_pr': r'http://pr/{repo}/pr/\1',
+            'issue_sub_pr': r'PR#\1',
+            'issue_pat_bug': r'(?:BUG|bug|issue) ?#?(\d+)',
+            'issue_server_link_bug': r'http://bug/{repo}/bug/\1',
+            'issue_sub_bug': r'bug#\1',
+            'issue_pat_empty_prefix': r'FAIL(\d+)',
+            'issue_server_link_empty_prefix': r'http://fail/{repo}/\1',
+            'issue_sub_empty_prefix': r'',
+            'issue_pat_absent_prefix': r'FAILMORE(\d+)',
+            'issue_server_link_absent_prefix': r'http://failmore/{repo}/\1',
         }
         # force recreation of lazy function
         with mock.patch('kallithea.lib.helpers._urlify_issues_f', None):
--- a/kallithea/tests/scripts/manual_test_crawler.py	Mon Nov 11 00:38:52 2019 +0100
+++ b/kallithea/tests/scripts/manual_test_crawler.py	Mon Dec 16 02:29:34 2019 +0100
@@ -130,13 +130,13 @@
             break
 
         full_uri = (BASE_URI % raw_cs)
-        print('%s visiting %s\%s' % (cnt, full_uri, i))
+        print('%s visiting %s/%s' % (cnt, full_uri, i))
         s = time.time()
         f = o.open(full_uri)
         size = len(f.read())
         e = time.time() - s
         total_time += e
-        print('%s visited %s\%s size:%s req:%s ms' % (cnt, full_uri, i, size, e))
+        print('%s visited %s/%s size:%s req:%s ms' % (cnt, full_uri, i, size, e))
 
     print('total_time', total_time)
     print('average on req', total_time / float(cnt))
--- a/kallithea/tests/vcs/test_repository.py	Mon Nov 11 00:38:52 2019 +0100
+++ b/kallithea/tests/vcs/test_repository.py	Mon Dec 16 02:29:34 2019 +0100
@@ -110,7 +110,7 @@
 
     def test_initial_commit_diff(self):
         initial_rev = self.repo.revisions[0]
-        assert self.repo.get_diff(self.repo.EMPTY_CHANGESET, initial_rev) == '''diff --git a/foobar b/foobar
+        assert self.repo.get_diff(self.repo.EMPTY_CHANGESET, initial_rev) == r'''diff --git a/foobar b/foobar
 new file mode 100644
 index 0000000000000000000000000000000000000000..f6ea0495187600e7b2288c8ac19c5886383a4632
 --- /dev/null
@@ -130,7 +130,7 @@
 
     def test_second_changeset_diff(self):
         revs = self.repo.revisions
-        assert self.repo.get_diff(revs[0], revs[1]) == '''diff --git a/foobar b/foobar
+        assert self.repo.get_diff(revs[0], revs[1]) == r'''diff --git a/foobar b/foobar
 index f6ea0495187600e7b2288c8ac19c5886383a4632..389865bb681b358c9b102d79abd8d5f941e96551 100644
 --- a/foobar
 +++ b/foobar
@@ -151,7 +151,7 @@
 
     def test_third_changeset_diff(self):
         revs = self.repo.revisions
-        assert self.repo.get_diff(revs[1], revs[2]) == '''diff --git a/foobar b/foobar
+        assert self.repo.get_diff(revs[1], revs[2]) == r'''diff --git a/foobar b/foobar
 deleted file mode 100644
 index 389865bb681b358c9b102d79abd8d5f941e96551..0000000000000000000000000000000000000000
 --- a/foobar
@@ -173,7 +173,7 @@
 
     def test_fourth_changeset_diff(self):
         revs = self.repo.revisions
-        assert self.repo.get_diff(revs[2], revs[3]) == '''diff --git a/README{ b/README{
+        assert self.repo.get_diff(revs[2], revs[3]) == r'''diff --git a/README{ b/README{
 new file mode 100644
 index 0000000000000000000000000000000000000000..cdc0c1b5d234feedb37bbac19cd1b6442061102d
 --- /dev/null
@@ -189,7 +189,7 @@
 
     def test_initial_commit_diff(self):
         initial_rev = self.repo.revisions[0]
-        assert self.repo.get_diff(self.repo.EMPTY_CHANGESET, initial_rev) == '''diff --git a/foobar b/foobar
+        assert self.repo.get_diff(self.repo.EMPTY_CHANGESET, initial_rev) == r'''diff --git a/foobar b/foobar
 new file mode 100644
 --- /dev/null
 +++ b/foobar
@@ -207,7 +207,7 @@
 
     def test_second_changeset_diff(self):
         revs = self.repo.revisions
-        assert self.repo.get_diff(revs[0], revs[1]) == '''diff --git a/foobar b/foobar
+        assert self.repo.get_diff(revs[0], revs[1]) == r'''diff --git a/foobar b/foobar
 --- a/foobar
 +++ b/foobar
 @@ -1,1 +1,1 @@
@@ -226,7 +226,7 @@
 
     def test_third_changeset_diff(self):
         revs = self.repo.revisions
-        assert self.repo.get_diff(revs[1], revs[2]) == '''diff --git a/foobar b/foobar
+        assert self.repo.get_diff(revs[1], revs[2]) == r'''diff --git a/foobar b/foobar
 deleted file mode 100644
 --- a/foobar
 +++ /dev/null
@@ -246,7 +246,7 @@
 
     def test_fourth_changeset_diff(self):
         revs = self.repo.revisions
-        assert self.repo.get_diff(revs[2], revs[3]) == '''diff --git a/README{ b/README{
+        assert self.repo.get_diff(revs[2], revs[3]) == r'''diff --git a/README{ b/README{
 new file mode 100644
 --- /dev/null
 +++ b/README{