diff --git a/dev/run-tests-docker.py b/dev/run-tests-docker.py index 4cff364..525a8f9 100755 --- a/dev/run-tests-docker.py +++ b/dev/run-tests-docker.py @@ -6,15 +6,15 @@ from string import Template TEMPLATE = 'dev/docker/test_env_template' -PKG_LIST = 'python-alembic python-arrow python-binaryornot \ \n'\ - 'python-bleach python-blinker python-chardet python-cryptography \ \n'\ - 'python-docutils python-enum34 python-flask python2-fedora-flask \ \n'\ - 'python-flask-wtf python2-bcrypt python-jinja2 \ \n'\ - 'python-markdown python-munch python-openid-cla python-openid-teams \ \n'\ - 'python-psutil python-pygit2 python2-pillow \ \n'\ - 'python-sqlalchemy python-straight-plugin python-wtforms python-nose \ \n'\ - 'python3-coverage python-mock python-mock python-eventlet python2-flask-oidc \ \n'\ - 'python-flake8 python-celery python-redis python-trololio python-beautifulsoup4 redis vim git' +PKG_LIST = r'python-alembic python-arrow python-binaryornot \ \n'\ + r'python-bleach python-blinker python-chardet python-cryptography \ \n'\ + r'python-docutils python-enum34 python-flask python2-fedora-flask \ \n'\ + r'python-flask-wtf python2-bcrypt python-jinja2 \ \n'\ + r'python-markdown python-munch python-openid-cla python-openid-teams \ \n'\ + r'python-psutil python-pygit2 python2-pillow \ \n'\ + r'python-sqlalchemy python-straight-plugin python-wtforms python-nose \ \n'\ + r'python3-coverage python-mock python-mock python-eventlet python2-flask-oidc \ \n'\ + r'python-flake8 python-celery python-redis python-trololio python-beautifulsoup4 redis vim git' def setup_parser(): diff --git a/pagure/lib/link.py b/pagure/lib/link.py index 2d50bfb..3d78390 100644 --- a/pagure/lib/link.py +++ b/pagure/lib/link.py @@ -21,19 +21,19 @@ FIXES = [ re.compile(r"(?:.*\s+)?fixe?[sd]?:?\s*?#(\d+)", re.I), re.compile( r"(?:.*\s+)?fixe?[sd]?:?\s*?https?://.*/([a-zA-z0-9_][a-zA-Z0-9-_]*)" - "/(?:issue|pull-request)/(\d+)", + r"/(?:issue|pull-request)/(\d+)", re.I, ), re.compile(r"(?:.*\s+)?merge?[sd]?:?\s*?#(\d+)", re.I), re.compile( r"(?:.*\s+)?merge?[sd]?:?\s*?https?://.*/([a-zA-z0-9_][a-zA-Z0-9-_]*)" - "/(?:issue|pull-request)/(\d+)", + r"/(?:issue|pull-request)/(\d+)", re.I, ), re.compile(r"(?:.*\s+)?close?[sd]?:?\s*?#(\d+)", re.I), re.compile( r"(?:.*\s+)?close?[sd]?:?\s*?https?://.*/([a-zA-z0-9_][a-zA-Z0-9-_]*)" - "/(?:issue|pull-request)/(\d+)", + r"/(?:issue|pull-request)/(\d+)", re.I, ), ] @@ -43,7 +43,7 @@ RELATES = [ re.compile(r"(?:.*\s+)?relate[sd]?:?\s?#(\d+)", re.I), re.compile( r"(?:.*\s+)?relate[sd]?:?\s*?(?:to)?\s*?" - "https?://.*/([a-zA-z0-9_][a-zA-Z0-9-_]*)/issue/(\d+)", + r"https?://.*/([a-zA-z0-9_][a-zA-Z0-9-_]*)/issue/(\d+)", re.I, ), ] diff --git a/pagure/lib/model.py b/pagure/lib/model.py index 2725665..b2ea0a3 100644 --- a/pagure/lib/model.py +++ b/pagure/lib/model.py @@ -1295,9 +1295,9 @@ class Issue(BASE): def extract_info(text): """ Return a tuple containing the link, file name, and the "display" file name from the markdown attachment link """ - pattern_md = re.compile("^\[\!(.*)\]") - pattern_link = re.compile("\(([^)]+)\)") - pattern_file = re.compile("\[([^]]+)\]") + pattern_md = re.compile(r"^\[\!(.*)\]") + pattern_link = re.compile(r"\(([^)]+)\)") + pattern_file = re.compile(r"\[([^]]+)\]") try: md_link = pattern_md.search(text).group(1) diff --git a/pagure/ui/repo.py b/pagure/ui/repo.py index b84d5d4..086cda3 100644 --- a/pagure/ui/repo.py +++ b/pagure/ui/repo.py @@ -3164,7 +3164,7 @@ def update_tags(repo, username=None, namespace=None): ) error = True - color_pattern = re.compile("^#\w{3,6}$") + color_pattern = re.compile(r"^#\w{3,6}$") for color in colors: if not color_pattern.match(color): flask.flash( diff --git a/tests/__init__.py b/tests/__init__.py index b8022e3..beb52e5 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -125,7 +125,7 @@ REPOSPANNER_REGIONS = { LOG.info('BUILD_ID: %s', os.environ.get('BUILD_ID')) -WAIT_REGEX = re.compile("""var _url = '(\/wait\/[a-z0-9-]+\??.*)'""") +WAIT_REGEX = re.compile(r"""var _url = '(\/wait\/[a-z0-9-]+\??.*)'""") def get_wait_target(html): """ This parses the window.location out of the HTML for the wait page. """ found = WAIT_REGEX.findall(html) diff --git a/tests/test_pagure_flask_ui_fork.py b/tests/test_pagure_flask_ui_fork.py index d1a4194..e7a9a28 100644 --- a/tests/test_pagure_flask_ui_fork.py +++ b/tests/test_pagure_flask_ui_fork.py @@ -1183,7 +1183,7 @@ class PagureFlaskForktests(tests.Modeltests): row = row.split(' ', 2)[2] npatch.append(row) - exp = """Mon Sep 17 00:00:00 2001 + exp = r"""Mon Sep 17 00:00:00 2001 From: Alice Author Subject: A commit on branch feature @@ -1249,7 +1249,7 @@ index 9f44358..2a552bb 100644 output = self.app.get('/test/pull-request/1.diff') self.assertEqual(output.status_code, 200) - exp = """diff --git a/.gitignore b/.gitignore + exp = r"""diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e4e5f6c --- /dev/null @@ -1302,7 +1302,7 @@ index 9f44358..2a552bb 100644 row = row.split(' ', 2)[2] npatch.append(row) - exp = """Mon Sep 17 00:00:00 2001 + exp = r"""Mon Sep 17 00:00:00 2001 From: Alice Author Subject: A commit on branch feature @@ -1419,7 +1419,7 @@ index 9f44358..2a552bb 100644 row = row.split(' ', 2)[2] npatch.append(row) - exp = """Mon Sep 17 00:00:00 2001 + exp = r"""Mon Sep 17 00:00:00 2001 From: Alice Author Subject: A commit on branch feature diff --git a/tests/test_pagure_flask_ui_quick_reply.py b/tests/test_pagure_flask_ui_quick_reply.py index 0fc4efd..1563ab5 100644 --- a/tests/test_pagure_flask_ui_quick_reply.py +++ b/tests/test_pagure_flask_ui_quick_reply.py @@ -91,7 +91,7 @@ class PagureFlaskQuickReplytest(tests.Modeltests): def assertQuickReplyLinks(self, output): """Assert reply links created by setup_quick_replies are present.""" - link = 'data-qr="%s">\s*%s\s*' + link = r'data-qr="%s">\s*%s\s*' six.assertRegex( self, output.get_data(as_text=True), diff --git a/tests/test_pagure_flask_ui_repo.py b/tests/test_pagure_flask_ui_repo.py index e8d957d..43dfa4c 100644 --- a/tests/test_pagure_flask_ui_repo.py +++ b/tests/test_pagure_flask_ui_repo.py @@ -2571,7 +2571,7 @@ class PagureFlaskRepotests(tests.Modeltests): output = self.app.get('/test/blame/foofile') self.assertEqual(output.status_code, 404) - regex = re.compile('>(\w+)\n') + regex = re.compile(r'>(\w+)\n') # View in master branch output = self.app.get('/test/blame/sources') @@ -2704,7 +2704,7 @@ class PagureFlaskRepotests(tests.Modeltests): def test_view_blame_file_on_tag(self): """ Test the view_blame_file endpoint. """ - regex = re.compile('>(\w+)\n') + regex = re.compile(r'>(\w+)\n') tests.create_projects(self.session) tests.create_projects_git(os.path.join(self.path, 'repos'), bare=True) # Add some content to the git repo @@ -2906,7 +2906,7 @@ class PagureFlaskRepotests(tests.Modeltests): output = self.app.get('/test/c/%s.patch' % commit.oid.hex) self.assertEqual(output.status_code, 200) output_text = output.get_data(as_text=True) - self.assertIn('''diff --git a/README.rst b/README.rst + self.assertIn(r'''diff --git a/README.rst b/README.rst new file mode 100644 index 0000000..fb7093d --- /dev/null @@ -2945,7 +2945,7 @@ index 0000000..fb7093d self.assertIn( 'Subject: Add some directory and a file for more testing', output_text) - self.assertIn('''diff --git a/folder1/folder2/file b/folder1/folder2/file + self.assertIn(r'''diff --git a/folder1/folder2/file b/folder1/folder2/file new file mode 100644 index 0000000..11980b1 --- /dev/null @@ -2986,7 +2986,7 @@ index 0000000..11980b1 '/fork/pingou/test3/c/%s.patch' % commit.oid.hex) self.assertEqual(output.status_code, 200) output_text = output.get_data(as_text=True) - self.assertIn('''diff --git a/README.rst b/README.rst + self.assertIn(r'''diff --git a/README.rst b/README.rst new file mode 100644 index 0000000..fb7093d --- /dev/null @@ -3037,7 +3037,7 @@ index 0000000..fb7093d output = self.app.get('/test/c/%s.diff' % commit.oid.hex) self.assertEqual(output.status_code, 200) output_text = output.get_data(as_text=True) - self.assertEqual('''diff --git a/README.rst b/README.rst + self.assertEqual(r'''diff --git a/README.rst b/README.rst new file mode 100644 index 0000000..fb7093d --- /dev/null diff --git a/tests/test_pagure_lib_git.py b/tests/test_pagure_lib_git.py index d9f10b2..69e3576 100644 --- a/tests/test_pagure_lib_git.py +++ b/tests/test_pagure_lib_git.py @@ -1426,7 +1426,7 @@ repo requests/forks/pingou/test3 # Use patch to validate the repo commit_patch = pagure.lib.git.commit_to_patch(repo, commit) - exp = """Mon Sep 17 00:00:00 2001 + exp = r"""Mon Sep 17 00:00:00 2001 From: pagure Subject: Updated issue : Test issue @@ -1525,7 +1525,7 @@ index 0000000..60f7480 repo = pygit2.Repository(self.gitrepo) commit = repo.revparse_single('HEAD') commit_patch = pagure.lib.git.commit_to_patch(repo, commit) - exp = """Mon Sep 17 00:00:00 2001 + exp = r"""Mon Sep 17 00:00:00 2001 From: pagure Subject: Updated issue : Test issue @@ -1686,7 +1686,7 @@ index 458821a..77674a8 # Use patch to validate the repo patch = pagure.lib.git.commit_to_patch(repo, commit) - exp = """Mon Sep 17 00:00:00 2001 + exp = r"""Mon Sep 17 00:00:00 2001 From: pagure Subject: Updated pull-request : test PR @@ -3088,7 +3088,7 @@ class PagureLibGitCommitToPatchtests(tests.Modeltests): repo = pygit2.init_repository(self.gitrepo) patch = pagure.lib.git.commit_to_patch(repo, self.first_commit) - exp = """Mon Sep 17 00:00:00 2001 + exp = r"""Mon Sep 17 00:00:00 2001 From: Alice Author Subject: Add sources file for testing @@ -3122,7 +3122,7 @@ index 0000000..9f44358 repo = pygit2.init_repository(self.gitrepo) patch = pagure.lib.git.commit_to_patch(repo, self.second_commit) - exp = """Mon Sep 17 00:00:00 2001 + exp = r"""Mon Sep 17 00:00:00 2001 From: Alice Author Subject: Add baz and boose to the sources @@ -3161,7 +3161,7 @@ index 9f44358..2a552bb 100644 patch = pagure.lib.git.commit_to_patch( repo, [self.first_commit, self.second_commit]) - exp = """Mon Sep 17 00:00:00 2001 + exp = r"""Mon Sep 17 00:00:00 2001 From: Alice Author Subject: [PATCH 1/2] Add sources file for testing @@ -3217,7 +3217,7 @@ index 9f44358..2a552bb 100644 patch = pagure.lib.git.commit_to_patch( repo, self.first_commit, diff_view=True) - exp = """diff --git a/sources b/sources + exp = r"""diff --git a/sources b/sources new file mode 100644 index 0000000..9f44358 --- /dev/null @@ -3244,7 +3244,7 @@ index 0000000..9f44358 patch = pagure.lib.git.commit_to_patch( repo, self.second_commit, diff_view=True) - exp = """diff --git a/sources b/sources + exp = r"""diff --git a/sources b/sources index 9f44358..2a552bb 100644 --- a/sources +++ b/sources @@ -3274,7 +3274,7 @@ index 9f44358..2a552bb 100644 patch = pagure.lib.git.commit_to_patch( repo, [self.first_commit, self.second_commit], diff_view=True) - exp = """diff --git a/sources b/sources + exp = r"""diff --git a/sources b/sources new file mode 100644 index 0000000..9f44358 --- /dev/null @@ -3313,7 +3313,7 @@ index 9f44358..2a552bb 100644 patches = pagure.lib.git.commit_to_patch( repo, self.first_commit, diff_view=True, separated=True) - exp = """diff --git a/sources b/sources + exp = r"""diff --git a/sources b/sources new file mode 100644 index 0000000..9f44358 --- /dev/null @@ -3344,7 +3344,7 @@ index 0000000..9f44358 patches = pagure.lib.git.commit_to_patch( repo, self.second_commit, diff_view=True, separated=True) - exp = """diff --git a/sources b/sources + exp = r"""diff --git a/sources b/sources index 9f44358..2a552bb 100644 --- a/sources +++ b/sources @@ -3379,7 +3379,7 @@ index 9f44358..2a552bb 100644 patches = pagure.lib.git.commit_to_patch( repo, [self.first_commit, self.second_commit], diff_view=True, separated=True) - exp = ["""diff --git a/sources b/sources + exp = [r"""diff --git a/sources b/sources new file mode 100644 index 0000000..9f44358 --- /dev/null @@ -3389,7 +3389,7 @@ index 0000000..9f44358 + bar \ No newline at end of file """, -"""diff --git a/sources b/sources +r"""diff --git a/sources b/sources index 9f44358..2a552bb 100644 --- a/sources +++ b/sources diff --git a/tests/test_pagure_lib_gitolite_config.py b/tests/test_pagure_lib_gitolite_config.py index 56add8d..a4e6315 100644 --- a/tests/test_pagure_lib_gitolite_config.py +++ b/tests/test_pagure_lib_gitolite_config.py @@ -101,7 +101,7 @@ class PagureLibGitoliteConfigtests(tests.Modeltests): self.postconf = os.path.join(self.path, 'footer_gitolite') with open(self.postconf, 'w', encoding="utf-8") as stream: stream.write('# end of generated configuration\n') - stream.write('# \ó/\n') + stream.write(r'# \ó/\n') stream.write('# end of footer\n') def tearDown(self): @@ -129,7 +129,7 @@ class PagureLibGitoliteConfigtests(tests.Modeltests): with open(self.outputconf, 'r') as stream: data = stream.read() - exp = """# this is a header that is manually added + exp = r"""# this is a header that is manually added @group1 = foo bar baz @group2 = threebean puiterwijk kevin pingou @@ -187,7 +187,7 @@ class PagureLibGitoliteConfigtests(tests.Modeltests): with open(self.outputconf) as stream: data = stream.read() - exp = """# this is a header that is manually added + exp = r"""# this is a header that is manually added @group1 = foo bar baz @group2 = threebean puiterwijk kevin pingou @@ -227,7 +227,7 @@ class PagureLibGitoliteConfigtests(tests.Modeltests): with open(self.outputconf) as stream: data = stream.read() - exp = """# this is a header that is manually added + exp = r"""# this is a header that is manually added @group1 = foo bar baz @group2 = threebean puiterwijk kevin pingou @@ -294,7 +294,7 @@ repo requests/test with open(self.outputconf) as stream: data = stream.read() - exp = """# this is a header that is manually added + exp = r"""# this is a header that is manually added @group1 = foo bar baz @group2 = threebean puiterwijk kevin pingou @@ -468,7 +468,7 @@ class PagureLibGitoliteGroupConfigtests(tests.Modeltests): self.postconf = os.path.join(self.path, 'footer_gitolite') with open(self.postconf, 'w') as stream: stream.write('# end of generated configuration\n') - stream.write('# \ó/\n') + stream.write(r'# \ó/\n') stream.write('# end of footer\n') def tearDown(self): @@ -502,7 +502,7 @@ class PagureLibGitoliteGroupConfigtests(tests.Modeltests): with open(self.outputconf) as stream: data = stream.read() - exp = """# this is a header that is manually added + exp = r"""# this is a header that is manually added @group1 = foo bar baz @group2 = threebean puiterwijk kevin pingou @@ -554,7 +554,7 @@ repo requests/test with open(self.outputconf) as stream: data = stream.read() - exp = """# this is a header that is manually added + exp = r"""# this is a header that is manually added @group1 = foo bar baz @group2 = threebean puiterwijk kevin pingou @@ -606,7 +606,7 @@ repo requests/test with open(self.outputconf) as stream: data = stream.read() - exp = """# this is a header that is manually added + exp = r"""# this is a header that is manually added @group1 = foo bar baz @group2 = threebean puiterwijk kevin pingou @@ -672,7 +672,7 @@ repo requests/test with open(self.outputconf) as stream: data = stream.read() - exp = """# this is a header that is manually added + exp = r"""# this is a header that is manually added @group1 = foo bar baz @group2 = threebean puiterwijk kevin pingou @@ -765,7 +765,7 @@ repo requests/test with open(self.outputconf) as stream: data = stream.read() - exp = """# this is a header that is manually added + exp = r"""# this is a header that is manually added @group1 = foo bar baz @group2 = threebean puiterwijk kevin pingou