diff options
author | Stephen Finucane <sfinucan@redhat.com> | 2019-08-26 22:00:18 +0100 |
---|---|---|
committer | Stephen Finucane <sfinucan@redhat.com> | 2019-08-27 16:57:23 +0100 |
commit | fa0dd5652d82f8d238742f2d50c5514dec6f29a8 (patch) | |
tree | 180daafc6583de3d50648f0090958a7b7d304519 | |
parent | ef2269d5dbe3b9f6b690f51f94f8c09f23bdb11b (diff) | |
download | pbr-fa0dd5652d82f8d238742f2d50c5514dec6f29a8.tar.gz |
Mark strings as raw
Resolves the following deprecation warning:
DeprecationWarning: invalid escape sequence \.
Change-Id: If0bc30e646a3bb35c02dc73cc31fb146b3ecd6b5
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
-rw-r--r-- | pbr/git.py | 6 | ||||
-rw-r--r-- | pbr/packaging.py | 28 | ||||
-rw-r--r-- | pbr/tests/test_packaging.py | 12 | ||||
-rw-r--r-- | pbr/tests/test_setup.py | 4 | ||||
-rw-r--r-- | pbr/tests/test_wsgi.py | 2 |
5 files changed, 26 insertions, 26 deletions
@@ -156,9 +156,9 @@ def _clean_changelog_message(msg): * Escapes '`' which is interpreted as a literal """ - msg = msg.replace('*', '\*') - msg = msg.replace('_', '\_') - msg = msg.replace('`', '\`') + msg = msg.replace('*', r'\*') + msg = msg.replace('_', r'\_') + msg = msg.replace('`', r'\`') return msg diff --git a/pbr/packaging.py b/pbr/packaging.py index 0947de2..932ccdb 100644 --- a/pbr/packaging.py +++ b/pbr/packaging.py @@ -110,20 +110,20 @@ def get_reqs_from_files(requirements_files): def egg_fragment(match): return re.sub(r'(?P<PackageName>[\w.-]+)-' - '(?P<GlobalVersion>' - '(?P<VersionTripple>' - '(?P<Major>0|[1-9][0-9]*)\.' - '(?P<Minor>0|[1-9][0-9]*)\.' - '(?P<Patch>0|[1-9][0-9]*)){1}' - '(?P<Tags>(?:\-' - '(?P<Prerelease>(?:(?=[0]{1}[0-9A-Za-z-]{0})(?:[0]{1})|' - '(?=[1-9]{1}[0-9]*[A-Za-z]{0})(?:[0-9]+)|' - '(?=[0-9]*[A-Za-z-]+[0-9A-Za-z-]*)(?:[0-9A-Za-z-]+)){1}' - '(?:\.(?=[0]{1}[0-9A-Za-z-]{0})(?:[0]{1})|' - '\.(?=[1-9]{1}[0-9]*[A-Za-z]{0})(?:[0-9]+)|' - '\.(?=[0-9]*[A-Za-z-]+[0-9A-Za-z-]*)' - '(?:[0-9A-Za-z-]+))*){1}){0,1}(?:\+' - '(?P<Meta>(?:[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))){0,1}))', + r'(?P<GlobalVersion>' + r'(?P<VersionTripple>' + r'(?P<Major>0|[1-9][0-9]*)\.' + r'(?P<Minor>0|[1-9][0-9]*)\.' + r'(?P<Patch>0|[1-9][0-9]*)){1}' + r'(?P<Tags>(?:\-' + r'(?P<Prerelease>(?:(?=[0]{1}[0-9A-Za-z-]{0})(?:[0]{1})|' + r'(?=[1-9]{1}[0-9]*[A-Za-z]{0})(?:[0-9]+)|' + r'(?=[0-9]*[A-Za-z-]+[0-9A-Za-z-]*)(?:[0-9A-Za-z-]+)){1}' + r'(?:\.(?=[0]{1}[0-9A-Za-z-]{0})(?:[0]{1})|' + r'\.(?=[1-9]{1}[0-9]*[A-Za-z]{0})(?:[0-9]+)|' + r'\.(?=[0-9]*[A-Za-z-]+[0-9A-Za-z-]*)' + r'(?:[0-9A-Za-z-]+))*){1}){0,1}(?:\+' + r'(?P<Meta>(?:[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))){0,1}))', r'\g<PackageName>>=\g<GlobalVersion>', match.groups()[-1]) diff --git a/pbr/tests/test_packaging.py b/pbr/tests/test_packaging.py index 811715b..c7dafda 100644 --- a/pbr/tests/test_packaging.py +++ b/pbr/tests/test_packaging.py @@ -108,7 +108,7 @@ class GPGKeyFixture(fixtures.Fixture): def setUp(self): super(GPGKeyFixture, self).setUp() tempdir = self.useFixture(fixtures.TempDir()) - gnupg_version_re = re.compile('^gpg\s.*\s([\d+])\.([\d+])\.([\d+])') + gnupg_version_re = re.compile(r'^gpg\s.*\s([\d+])\.([\d+])\.([\d+])') gnupg_version = base._run_cmd(['gpg', '--version'], tempdir.path) for line in gnupg_version[0].split('\n'): gnupg_version = gnupg_version_re.match(line) @@ -293,23 +293,23 @@ class TestPackagingInGitRepoWithCommit(base.BaseTestCase): self.run_setup('sdist', allow_fail=False) with open(os.path.join(self.package_dir, 'ChangeLog'), 'r') as f: body = f.read() - self.assertIn('\*', body) + self.assertIn(r'\*', body) def test_changelog_handles_dead_links_in_commit(self): self.repo.commit(message_content="See os_ for to_do about qemu_.") self.run_setup('sdist', allow_fail=False) with open(os.path.join(self.package_dir, 'ChangeLog'), 'r') as f: body = f.read() - self.assertIn('os\_', body) - self.assertIn('to\_do', body) - self.assertIn('qemu\_', body) + self.assertIn(r'os\_', body) + self.assertIn(r'to\_do', body) + self.assertIn(r'qemu\_', body) def test_changelog_handles_backticks(self): self.repo.commit(message_content="Allow `openstack.org` to `work") self.run_setup('sdist', allow_fail=False) with open(os.path.join(self.package_dir, 'ChangeLog'), 'r') as f: body = f.read() - self.assertIn('\`', body) + self.assertIn(r'\`', body) def test_manifest_exclude_honoured(self): self.run_setup('sdist', allow_fail=False) diff --git a/pbr/tests/test_setup.py b/pbr/tests/test_setup.py index 85d40eb..0e60df7 100644 --- a/pbr/tests/test_setup.py +++ b/pbr/tests/test_setup.py @@ -162,7 +162,7 @@ class GitLogsTest(base.BaseTestCase): self.assertIn("------", changelog_contents) self.assertIn("Refactor hooks file", changelog_contents) self.assertIn( - "Bug fix: create\_stack() fails when waiting", + r"Bug fix: create\_stack() fails when waiting", changelog_contents) self.assertNotIn("Refactor hooks file.", changelog_contents) self.assertNotIn("182feb3", changelog_contents) @@ -176,7 +176,7 @@ class GitLogsTest(base.BaseTestCase): self.assertNotIn("ev)il", changelog_contents) self.assertNotIn("e(vi)l", changelog_contents) self.assertNotIn('Merge "', changelog_contents) - self.assertNotIn('1\_foo.1', changelog_contents) + self.assertNotIn(r'1\_foo.1', changelog_contents) def test_generate_authors(self): author_old = u"Foo Foo <email@foo.com>" diff --git a/pbr/tests/test_wsgi.py b/pbr/tests/test_wsgi.py index 18732f7..a42fe78 100644 --- a/pbr/tests/test_wsgi.py +++ b/pbr/tests/test_wsgi.py @@ -98,7 +98,7 @@ class TestWsgiScripts(base.BaseTestCase): stdoutdata = p.stdout.readline() # Available at ... print(stdoutdata) - m = re.search(b'(http://[^:]+:\d+)/', stdoutdata) + m = re.search(br'(http://[^:]+:\d+)/', stdoutdata) self.assertIsNotNone(m, "Regex failed to match on %s" % stdoutdata) stdoutdata = p.stdout.readline() # DANGER! ... |