summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGES.rst5
-rw-r--r--coverage/backunittest.py5
-rw-r--r--doc/config.rst5
-rw-r--r--tests/test_summary_class.py41
4 files changed, 29 insertions, 27 deletions
diff --git a/CHANGES.rst b/CHANGES.rst
index 3cdb8e0d..3b232859 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -8,6 +8,10 @@ Change history for Coverage.py
Unreleased
----------
+- A new configuration option, ``report:sort``, controls what columns of the
+ text report is used to sort the rows. Thanks to Dan Wandschneider, this
+ closes `issue 199`_.
+
- The HTML report has a more-visible indicator for which column is being
sorted. Closes `issue 298`_, thanks to karlw00t.
@@ -29,6 +33,7 @@ Unreleased
- The `test_helpers` module has been moved into a separate pip-installable
package: `unittest-mixins`_.
+.. _issue 199: https://bitbucket.org/ned/coveragepy/issues/199/add-a-way-to-sort-the-text-report
.. _issue 231: https://bitbucket.org/ned/coveragepy/issues/231/various-default-behavior-in-report-phase
.. _issue 298: https://bitbucket.org/ned/coveragepy/issues/298/show-in-html-report-that-the-columns-are
.. _issue 396: https://bitbucket.org/ned/coveragepy/issues/396/coverage-xml-shouldnt-bail-out-on-parse
diff --git a/coverage/backunittest.py b/coverage/backunittest.py
index 29fea86f..09574ccb 100644
--- a/coverage/backunittest.py
+++ b/coverage/backunittest.py
@@ -40,8 +40,3 @@ class TestCase(unittest.TestCase):
if not unittest_has('assertRegex'):
def assertRegex(self, *args, **kwargs):
return self.assertRegexpMatches(*args, **kwargs)
-
- if not unittest_has('assertNotIn'):
- def assertNotIn(self, needle, haystack):
- self.assertTrue(needle not in haystack)
-
diff --git a/doc/config.rst b/doc/config.rst
index 800f6c82..993ead97 100644
--- a/doc/config.rst
+++ b/doc/config.rst
@@ -218,8 +218,9 @@ missing lines. See :ref:`cmd_summary` for more information.
``skip_covered`` (boolean, default False): Don't include files in the report
that are 100% covered files. See :ref:`cmd_summary` for more information.
-``sort`` (string, default Name, allowed values: Name, Stmts, Miss, Cover):
-Sort report by the named column.
+``sort`` (string, default "Name"): Sort report by the named column. Allowed
+values: "Name", "Stmts", "Miss", or "Cover".
+
.. _config_html:
diff --git a/tests/test_summary_class.py b/tests/test_summary_class.py
index fb455920..e3fac4c7 100644
--- a/tests/test_summary_class.py
+++ b/tests/test_summary_class.py
@@ -4,11 +4,14 @@
"""Test text-based summary reporter for coverage.py"""
-import collections
import os.path
-import sys
+
from coverage.backward import StringIO
-from coverage import backunittest, config, control, data, summary
+from coverage.backunittest import TestCase
+from coverage.config import CoverageConfig
+from coverage.control import Coverage
+from coverage.data import CoverageData
+from coverage.summary import SummaryReporter
LINES_1 = {
__file__: {-1: 1, 7: 1},
@@ -16,38 +19,36 @@ LINES_1 = {
}
-class TestSummaryReporterConfiguration(backunittest.TestCase):
- def get_coverage_data(self, lines=LINES_1):
+class TestSummaryReporterConfiguration(TestCase):
+ """Tests of SummaryReporter."""
+
+ def get_coverage_data(self, lines):
"""Get a CoverageData object that includes the requested lines."""
- data1 = data.CoverageData()
- data1.add_lines(lines)
- return data1
+ data = CoverageData()
+ data.add_lines(lines)
+ return data
def get_summary_text(self, coverage_data, options):
"""Get text output from the SummaryReporter."""
- cov = control.Coverage()
+ cov = Coverage()
cov.data = coverage_data
- printer = summary.SummaryReporter(cov, options)
+ printer = SummaryReporter(cov, options)
destination = StringIO()
printer.report([], destination)
return destination.getvalue()
- if sys.version_info < (2, 7):
- def assertNotIn(self, needle, haystack):
- self.assertTrue(needle not in haystack)
-
def test_defaults(self):
"""Run the report with no configuration options."""
- data = self.get_coverage_data()
- opts = config.CoverageConfig()
+ data = self.get_coverage_data(LINES_1)
+ opts = CoverageConfig()
report = self.get_summary_text(data, opts)
self.assertNotIn('Missing', report)
self.assertNotIn('Branch', report)
def test_print_missing(self):
"""Run the report printing the missing lines."""
- data = self.get_coverage_data()
- opts = config.CoverageConfig()
+ data = self.get_coverage_data(LINES_1)
+ opts = CoverageConfig()
opts.from_args(show_missing=True)
report = self.get_summary_text(data, opts)
self.assertTrue('Missing' in report)
@@ -55,8 +56,8 @@ class TestSummaryReporterConfiguration(backunittest.TestCase):
def test_sort_report(self):
"""Sort the text report."""
- data = self.get_coverage_data()
- opts = config.CoverageConfig()
+ data = self.get_coverage_data(LINES_1)
+ opts = CoverageConfig()
opts.from_args(sort='Stmts')
report = self.get_summary_text(data, opts)
# just the basename, to avoid pyc and directory name complexities