Use raw strings for all regexps.

No exceptions please.
This commit is contained in:
Matthias Urlichs committed 2019-01-28 14:14:23 +01:00
1 parent bba95e9000
commit f3fdac7e5a
11 files changed
+88 -87

No files matched your search

+4 -3
View File
@@ -61,7 +61,7 @@ class TestCommHelpers(unittest.TestCase):
self.assertEqual(input, actual)
else:
import re
match = re.search("S(\d+(\.\d+)?)", actual)
match = re.search(r"S(\d+(\.\d+)?)", actual)
if not match:
self.fail("No temperature found")
temperature = float(match.group(1))
@@ -103,14 +103,15 @@ class TestCommHelpers(unittest.TestCase):
m.update(input)
return m.hexdigest()
temp_regex = b'T:((\d*\.)\d+)'
# rb'' doesn't exist in Python2
temp_regex = r'T:((\d*\.)\d+)'.encode('utf-8')
temp_template = b"Temp: {}"
temp2_template = b"Temperature: {}"
temp_key = md5sum(temp_regex)
temp_template_key = md5sum(temp_template)
temp2_template_key = md5sum(temp2_template)
x_regex = b"X:(?P<x>\d+)"
x_regex = r"X:(?P<x>\d+)".encode('utf-8')
x_template = b"X: {x}"
x_key = md5sum(x_regex)
x_template_key = md5sum(x_template)