Use raw python strings for regex escapes in test summary

Python warns about "\d" and friends that aren't in raw quotes, so we add
the 'r'aw string-qualifier.

Signed-off-by: Scott Mcdermott <scott@smemsh.net>
This commit is contained in:
Scott Mcdermott 2024-08-20 19:00:24 -07:00 committed by Thomas Lauf
parent d502bf8ee4
commit 05b72bba6f

View file

@ -57,7 +57,7 @@ class TestSummary(TestCase):
code, out, err = self.t("summary :ids {:%Y-%m-%d} - {:%Y-%m-%d}".format(yesterday, tomorrow))
self.assertRegex(out, """
self.assertRegex(out, r"""
Wk ?Date Day ID Tags ?Start ?End Time Total
[ -]+
W\d{1,2} \d{4}-\d{2}-\d{2} .{3} @1 ?\d{1,2}:\d{2}:\d{2} \d{1,2}:\d{2}:\d{2} \d{1,2}:\d{2}:\d{2} \d{1,2}:\d{2}:\d{2}(
@ -76,7 +76,7 @@ W\d{1,2} \d{4}-\d{2}-\d{2} .{3} @1 ?\d{1,2}:\d{2}:\d{2} \d{1,2}:\d{2}:\d{2
code, out, err = self.t("summary :ids :all".format(yesterday, tomorrow))
self.assertRegex(out, """
self.assertRegex(out, r"""
Wk ?Date Day ID Tags ?Start ?End Time Total
[ -]+
W\d{1,2} \d{4}-\d{2}-\d{2} .{3} @1 ?\d{1,2}:\d{2}:\d{2} \d{1,2}:\d{2}:\d{2} \d{1,2}:\d{2}:\d{2} \d{1,2}:\d{2}:\d{2}(
@ -95,7 +95,7 @@ W\d{1,2} \d{4}-\d{2}-\d{2} .{3} @1 ?\d{1,2}:\d{2}:\d{2} \d{1,2}:\d{2}:\d{2
code, out, err = self.t("summary :ids {:%Y-%m-%d} - {:%Y-%m-%d}".format(yesterday, tomorrow))
self.assertRegex(out, """
self.assertRegex(out, r"""
Wk ?Date Day ID Tags ?Start End Time Total
[ -]+
W\d{1,2} \d{4}-\d{2}-\d{2} .{3} @1 ?\d{1,2}:\d{2}:\d{2}[ ]+- \d{1,2}:\d{2}:\d{2} \d{1,2}:\d{2}:\d{2}(
@ -114,7 +114,7 @@ W\d{1,2} \d{4}-\d{2}-\d{2} .{3} @1 ?\d{1,2}:\d{2}:\d{2}[ ]+- \d{1,2}:\d{2}
code, out, err = self.t("summary :ids :all".format(yesterday, tomorrow))
self.assertRegex(out, """
self.assertRegex(out, r"""
Wk ?Date Day ID Tags ?Start End Time Total
[ -]+
W\d{1,2} \d{4}-\d{2}-\d{2} .{3} @1 ?\d{1,2}:\d{2}:\d{2}[ ]+- \d{1,2}:\d{2}:\d{2} \d{1,2}:\d{2}:\d{2}(
@ -362,7 +362,7 @@ W10 2017-03-11 Sat @3 FOO 10:00:00 11:00:00 1:00:00
"""Summary should display empty intervals at midnight"""
self.t("track sod - sod")
code, out, err = self.t("summary :year")
self.assertRegex(out, """
self.assertRegex(out, r"""
Wk ?Date Day Tags ?Start ?End Time Total
[ -]+
W\d{1,2} \d{4}-\d{2}-\d{2} .{3} ?0:00:00 0:00:00 0:00:00 0:00:00