Skip to content

Commit

Permalink
Use raw python strings for regex escapes in test summary
Browse files Browse the repository at this point in the history
Python warns about "\d" and friends that aren't in raw quotes, so we add
the 'r'aw string-qualifier.

Signed-off-by: Scott <[email protected]>
  • Loading branch information
smemsh committed Aug 24, 2024
1 parent ceb4837 commit ec8b742
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions test/summary.t
Original file line number Diff line number Diff line change
Expand Up @@ -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}(
Expand All @@ -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}(
Expand All @@ -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}(
Expand All @@ -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}(
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit ec8b742

Please sign in to comment.