@@ -83,13 +83,6 @@ def assert_results(
83
83
result = get_text (page , f"span[class={ outcome } ]" )
84
84
assert_that (result ).is_equal_to (f"{ number } { OUTCOMES [outcome ]} " )
85
85
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
-
93
86
94
87
def get_element (page , selector ):
95
88
return page .select_one (selector )
@@ -150,12 +143,43 @@ def test_sleep():
150
143
)
151
144
page = run (pytester )
152
145
duration = get_text (page , "#results-table td[class='col-duration']" )
146
+ total_duration = get_text (page , "p[class='run-count']" )
153
147
if pause < 1 :
154
148
assert_that (int (duration .replace ("ms" , "" ))).is_between (
155
149
expectation , expectation * 2
156
150
)
151
+ assert_that (total_duration ).matches (r"\d+\s+ms" )
157
152
else :
158
153
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)" )
159
183
160
184
def test_pass (self , pytester ):
161
185
pytester .makepyfile ("def test_pass(): pass" )
0 commit comments