diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2021-10-12 08:46:25 -0400 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2021-10-12 08:46:25 -0400 |
commit | 0eaeb99f2de1330a562752d30d02d1898f681cf8 (patch) | |
tree | d51b41a302dddafd3092c0fc367b1676bab56a6d /coverage/summary.py | |
parent | 5b6b6ecb87f4aa1145977b1a4c8359b202da0d7a (diff) | |
download | python-coveragepy-git-0eaeb99f2de1330a562752d30d02d1898f681cf8.tar.gz |
fix: use human sorting on human-readable things
Diffstat (limited to 'coverage/summary.py')
-rw-r--r-- | coverage/summary.py | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/coverage/summary.py b/coverage/summary.py index b7b172f8..0b54a05b 100644 --- a/coverage/summary.py +++ b/coverage/summary.py @@ -6,6 +6,7 @@ import sys from coverage.exceptions import CoverageException +from coverage.misc import human_sorted_items from coverage.report import get_analysis_to_report from coverage.results import Numbers @@ -89,15 +90,17 @@ class SummaryReporter: lines.append((text, args)) # Sort the lines and write them out. - if getattr(self.config, 'sort', None): - sort_option = self.config.sort.lower() - reverse = False - if sort_option[0] == '-': - reverse = True - sort_option = sort_option[1:] - elif sort_option[0] == '+': - sort_option = sort_option[1:] - + sort_option = (self.config.sort or "name").lower() + reverse = False + if sort_option[0] == '-': + reverse = True + sort_option = sort_option[1:] + elif sort_option[0] == '+': + sort_option = sort_option[1:] + + if sort_option == "name": + lines = human_sorted_items(lines, reverse=reverse) + else: position = column_order.get(sort_option) if position is None: raise CoverageException(f"Invalid sorting option: {self.config.sort!r}") |