Skip to content

Commit f28b1db

Browse files
committed
Fix broken sorting tests. Good catch, Jerin Peter George
1 parent 97f05c9 commit f28b1db

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

tests/test_summary.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -866,13 +866,13 @@ def test_test_data(self):
866866
# sort in three different orders.
867867
report = self.get_summary_text()
868868
print(report)
869-
# Name Stmts Miss Cover
870-
# --------------------------------------------
871-
# tests/test_api.py 339 155 54%
872-
# tests/test_backward.py 13 3 77%
873-
# tests/test_coverage.py 234 228 3%
874-
# --------------------------------------------
875-
# TOTAL 586 386 34%
869+
# Name Stmts Miss Cover
870+
# ------------------------------
871+
# file1.py 339 155 54%
872+
# file2.py 13 3 77%
873+
# file3.py 234 228 3%
874+
# ------------------------------
875+
# TOTAL 586 386 34%
876876

877877
lines = report.splitlines()[2:-2]
878878
self.assertEqual(len(lines), 3)
@@ -901,6 +901,7 @@ def test_print_missing(self):
901901
def assert_ordering(self, text, *words):
902902
"""Assert that the `words` appear in order in `text`."""
903903
indexes = list(map(text.find, words))
904+
assert -1 not in indexes
904905
self.assertEqual(
905906
indexes, sorted(indexes),
906907
"The words %r don't appear in order in %r" % (words, text)
@@ -909,17 +910,17 @@ def assert_ordering(self, text, *words):
909910
def test_sort_report_by_stmts(self):
910911
# Sort the text report by the Stmts column.
911912
report = self.get_summary_text(('report:sort', 'Stmts'))
912-
self.assert_ordering(report, "test_backward.py", "test_coverage.py", "test_api.py")
913+
self.assert_ordering(report, "file2.py", "file3.py", "file1.py")
913914

914915
def test_sort_report_by_missing(self):
915916
# Sort the text report by the Missing column.
916917
report = self.get_summary_text(('report:sort', 'Miss'))
917-
self.assert_ordering(report, "test_backward.py", "test_api.py", "test_coverage.py")
918+
self.assert_ordering(report, "file2.py", "file1.py", "file3.py")
918919

919920
def test_sort_report_by_cover(self):
920921
# Sort the text report by the Cover column.
921922
report = self.get_summary_text(('report:sort', 'Cover'))
922-
self.assert_ordering(report, "test_coverage.py", "test_api.py", "test_backward.py")
923+
self.assert_ordering(report, "file3.py", "file1.py", "file2.py")
923924

924925
def test_sort_report_by_invalid_option(self):
925926
# Sort the text report by a nonsense column.

0 commit comments

Comments
 (0)