From 0b6744854b0fe03c10fb40038a1e791900ca9e19 Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Tue, 14 Jan 2020 14:06:04 +0000 Subject: [PATCH] Fix test that fails 1 in 60 times This test looks for how many times the string `50` appears in the text of the `
` element of the page. The `
` element also contains some times, for example 1:23pm. This means that when the time reaches 1:50pm, 2:50pm, etc the number of times the string `50` appears in the page changes. Which causes the test assertions to fail. --- tests/app/main/views/test_dashboard.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/app/main/views/test_dashboard.py b/tests/app/main/views/test_dashboard.py index a31f5bb89..ccc7924a7 100644 --- a/tests/app/main/views/test_dashboard.py +++ b/tests/app/main/views/test_dashboard.py @@ -552,8 +552,11 @@ def test_should_not_show_recent_templates_on_dashboard_if_only_one_template_used # count appears as total, but not per template expected_count = stats[0]['count'] assert expected_count == 50 - assert main.count(str(expected_count)) == 1 - assert '50 text messages sent' in normalize_spaces(main) + assert normalize_spaces( + page.select_one('#total-sms .big-number').text + ) == ( + '{} text messages sent'.format(expected_count) + ) @freeze_time("2016-07-01 12:00") # 4 months into 2016 financial year