@@ -83,13 +83,6 @@ def assert_results(
8383 result = get_text (page , f"span[class={ outcome } ]" )
8484 assert_that (result ).is_equal_to (f"{ number } { OUTCOMES [outcome ]} " )
8585
86- # if total_tests is not None:
87- # number_of_tests = total_tests
88- # total = get_text(page, "p[class='run-count']")
89- # expr = r"%d %s ran in \d+.\d+ seconds."
90- # % (number_of_tests, "tests" if number_of_tests > 1 else "test")
91- # assert_that(total).matches(expr)
92-
9386
9487def get_element (page , selector ):
9588 return page .select_one (selector )
@@ -150,12 +143,43 @@ def test_sleep():
150143 )
151144 page = run (pytester )
152145 duration = get_text (page , "#results-table td[class='col-duration']" )
146+ total_duration = get_text (page , "p[class='run-count']" )
153147 if pause < 1 :
154148 assert_that (int (duration .replace ("ms" , "" ))).is_between (
155149 expectation , expectation * 2
156150 )
151+ assert_that (total_duration ).matches (r"\d+\s+ms" )
157152 else :
158153 assert_that (duration ).matches (expectation )
154+ assert_that (total_duration ).matches (r"\d{2}:\d{2}:\d{2}" )
155+
156+ def test_total_number_of_tests_zero (self , pytester ):
157+ page = run (pytester )
158+ assert_results (page )
159+
160+ total = get_text (page , "p[class='run-count']" )
161+ assert_that (total ).matches (r"0 test(?!s)" )
162+
163+ def test_total_number_of_tests_singular (self , pytester ):
164+ pytester .makepyfile ("def test_pass(): pass" )
165+ page = run (pytester )
166+ assert_results (page , passed = 1 )
167+
168+ total = get_text (page , "p[class='run-count']" )
169+ assert_that (total ).matches (r"1 test(?!s)" )
170+
171+ def test_total_number_of_tests_plural (self , pytester ):
172+ pytester .makepyfile (
173+ """
174+ def test_pass_one(): pass
175+ def test_pass_two(): pass
176+ """
177+ )
178+ page = run (pytester )
179+ assert_results (page , passed = 2 )
180+
181+ total = get_text (page , "p[class='run-count']" )
182+ assert_that (total ).matches (r"2 tests(?!\S)" )
159183
160184 def test_pass (self , pytester ):
161185 pytester .makepyfile ("def test_pass(): pass" )
0 commit comments