Skip to content

Commit

Permalink
Use regex and less strict assertion to make test case less likely to
Browse files Browse the repository at this point in the history
fail due to the race condition.
  • Loading branch information
Kami committed Aug 14, 2023
1 parent 6701d95 commit 482ace2
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions libcloud/test/dns/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,21 +94,21 @@ def test_export_zone_to_bind_format_success(self):
lines1 = result.split("\n")
lines2 = content.split("\n")

date_str = "{}-{}-{} {}:{}:{}".format(
date_str = r"{}-{}-{} {}:{}:{}".format(
now.year,
zero_pad(now.month),
zero_pad(now.day),
zero_pad(now.hour),
zero_pad(now.minute),
zero_pad(now.second),
r"\d+",
r"\d+",
)
expected_header = "; Generated by Libcloud v{} on {} UTC".format(
expected_header = r"; Generated by Libcloud v{} on {} UTC".format(
__version__,
date_str,
)

self.assertEqual(lines1[0], expected_header)
self.assertEqual(lines2[0], expected_header)
self.assertRegex(lines1[0], expected_header)
self.assertRegex(lines2[0], expected_header)

for lines in [lines1, lines2]:
self.assertEqual(len(lines), 2 + 1 + 9)
Expand Down

0 comments on commit 482ace2

Please sign in to comment.