summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDan Wandschneider <daniel.wandschneider@schrodinger.com>2016-06-08 19:51:55 -0400
committerDan Wandschneider <daniel.wandschneider@schrodinger.com>2016-06-08 19:51:55 -0400
commita488a33ac1cb1d8443681814ee8c5d167e129e0d (patch)
tree313e7ec8d4e6606eb8ae54e40113d54eb5ce4f4e /tests
parent0c39e2f5774b78ca5025e8ffe0fbde4ab2e86abf (diff)
downloadpython-coveragepy-git-a488a33ac1cb1d8443681814ee8c5d167e129e0d.tar.gz
Issue 199: Sort text report.
Allows sorting of the text report based on: Name, Stmts, Miss, Cover Tested on Mac with Python 2.7.11 and Python 3.5 Help message for the new option is: python -m coverage report -h ... --sort=SORT Sort report by a column. Valid values are: Name, Stmts, Miss, Cover. ...
Diffstat (limited to 'tests')
-rw-r--r--tests/test_cmdline.py7
-rw-r--r--tests/test_summary_class.py12
2 files changed, 18 insertions, 1 deletions
diff --git a/tests/test_cmdline.py b/tests/test_cmdline.py
index 8e2840b4..1fefb029 100644
--- a/tests/test_cmdline.py
+++ b/tests/test_cmdline.py
@@ -43,7 +43,7 @@ class BaseCmdLineTest(CoverageTest):
)
defaults.report(
ignore_errors=None, include=None, omit=None, morfs=[],
- show_missing=None, skip_covered=None
+ show_missing=None, skip_covered=None, sort_name=None
)
defaults.xml_report(
ignore_errors=None, include=None, omit=None, morfs=[], outfile=None,
@@ -341,6 +341,11 @@ class CmdLineTest(BaseCmdLineTest):
.load()
.report(skip_covered=True)
""")
+ self.cmd_executes("report --sort Stmts", """\
+ .coverage()
+ .load()
+ .report(sort_name='Stmts')
+ """)
def test_run(self):
# coverage run [-p] [-L] [--timid] MODULE.py [ARG1 ARG2 ...]
diff --git a/tests/test_summary_class.py b/tests/test_summary_class.py
index 93e025c4..2a8cd7c6 100644
--- a/tests/test_summary_class.py
+++ b/tests/test_summary_class.py
@@ -51,3 +51,15 @@ class TestSummaryReporterConfiguration(unittest.TestCase):
report = self.get_summary_text(data, opts)
self.assertIn('Missing', report)
self.assertNotIn('Branch', report)
+
+ def test_sort_report(self):
+ """Sort the text report."""
+ data = self.get_coverage_data()
+ opts = config.CoverageConfig()
+ opts.from_args(sort='Stmts')
+ report = self.get_summary_text(data, opts)
+ # just the basename, to avoid pyc and directory name complexities
+ filename = os.path.splitext(os.path.basename(__file__))[0]
+ location1 = report.find('helpers')
+ location2 = report.find(filename)
+ self.assertLess(location1, location2)