@@ -823,6 +823,52 @@ def test_log_escaping(self, pytester, outcome, occurrence):
823823 count = log .count (each )
824824 assert_that (count ).is_equal_to (occurrence )
825825
826+ @pytest .mark .parametrize (
827+ "sort, order" ,
828+ [
829+ (None , ["BBB" , "AAA" , "CCC" ]),
830+ ("result" , ["BBB" , "AAA" , "CCC" ]),
831+ ("testId" , ["AAA" , "BBB" , "CCC" ]),
832+ ("duration" , ["CCC" , "BBB" , "AAA" ]),
833+ ("original" , ["AAA" , "BBB" , "CCC" ]),
834+ ],
835+ )
836+ def test_initial_sort (self , pytester , sort , order ):
837+ if sort is not None :
838+ pytester .makeini (
839+ f"""
840+ [pytest]
841+ initial_sort = { sort }
842+ """
843+ )
844+
845+ pytester .makepyfile (
846+ """
847+ import pytest
848+ from time import sleep
849+
850+ def test_AAA():
851+ sleep(0.3)
852+ assert True
853+
854+ def test_BBB():
855+ sleep(0.2)
856+ assert False
857+
858+ def test_CCC():
859+ sleep(0.1)
860+ assert True
861+ """
862+ )
863+
864+ page = run (pytester )
865+ assert_results (page , passed = 2 , failed = 1 )
866+
867+ result = page .select ("td.col-testId" )
868+ assert_that (result ).is_length (3 )
869+ for row , expected in zip (result , order ):
870+ assert_that (row .string ).contains (expected )
871+
826872
827873class TestLogCapturing :
828874 LOG_LINE_REGEX = r"\s+this is {}"
0 commit comments