summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2016-05-20 10:30:09 -0400
committerNed Batchelder <ned@nedbatchelder.com>2016-05-20 10:30:09 -0400
commitfffbba825cc289b596828fd6542b8a9f7f79074a (patch)
treec425203b540bdd5c0827ca48568acf9b3228cc11
parentb3ccb992e084503e6718680a24b9efaee1b24c2c (diff)
downloadpython-coveragepy-fffbba825cc289b596828fd6542b8a9f7f79074a.tar.gz
Restore Reporter.file_reporters, with a deprecation warning.
-rw-r--r--CHANGES.rst8
-rw-r--r--coverage/report.py18
-rw-r--r--tests/test_api.py16
3 files changed, 41 insertions, 1 deletions
diff --git a/CHANGES.rst b/CHANGES.rst
index dd1e673..0d8a6d8 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -6,6 +6,14 @@ Change history for Coverage.py
==============================
+Unreleased
+----------
+
+- The internal attribute `Reporter.file_reporters` was removed in 4.1b3. It
+ should have come has no surprise that there were third-party tools out there
+ using that attribute. It has been restored, but with a deprecation warning.
+
+
Version 4.1b3 --- 2016-05-10
----------------------------
diff --git a/coverage/report.py b/coverage/report.py
index c3d59af..0d1519f 100644
--- a/coverage/report.py
+++ b/coverage/report.py
@@ -4,6 +4,7 @@
"""Reporter foundation for coverage.py."""
import os
+import warnings
from coverage.files import prep_patterns, FnmatchMatcher
from coverage.misc import CoverageException, NoSource, NotPython, isolate_module
@@ -28,6 +29,20 @@ class Reporter(object):
# classes.
self.directory = None
+ # Our method find_file_reporters used to set an attribute that other
+ # code could read. That's been refactored away, but some third parties
+ # were using that attribute. We'll continue to support it in a noisy
+ # way for now.
+ self._file_reporters = []
+
+ @property
+ def file_reporters(self):
+ warnings.warn(
+ "Report.file_reporters will no longer be available in Coverage.py 4.2",
+ DeprecationWarning,
+ )
+ return self._file_reporters
+
def find_file_reporters(self, morfs):
"""Find the FileReporters we'll report on.
@@ -46,7 +61,8 @@ class Reporter(object):
matcher = FnmatchMatcher(prep_patterns(self.config.omit))
reporters = [fr for fr in reporters if not matcher.match(fr.filename)]
- return sorted(reporters)
+ self._file_reporters = sorted(reporters)
+ return self._file_reporters
def report_files(self, report_fn, morfs, directory=None):
"""Run a reporting function on a number of morfs.
diff --git a/tests/test_api.py b/tests/test_api.py
index f849695..55cdbe8 100644
--- a/tests/test_api.py
+++ b/tests/test_api.py
@@ -7,11 +7,13 @@ import fnmatch
import os
import sys
import textwrap
+import warnings
import coverage
from coverage import env
from coverage.backward import StringIO
from coverage.misc import CoverageException
+from coverage.report import Reporter
from tests.coveragetest import CoverageTest
@@ -560,3 +562,17 @@ class TestRunnerPluginTest(CoverageTest):
def test_nose_plugin_with_erase(self):
self.pretend_to_be_nose_with_cover(erase=True)
+
+
+class ReporterDeprecatedAttributeTest(CoverageTest):
+ """Test that Reporter.file_reporters has been deprecated."""
+
+ run_in_temp_dir = False
+
+ def test_reporter_file_reporters(self):
+ rep = Reporter(None, None)
+ with warnings.catch_warnings(record=True) as warns:
+ warnings.simplefilter("always")
+ rep.file_reporters
+ self.assertEqual(len(warns), 1)
+ self.assertTrue(issubclass(warns[0].category, DeprecationWarning))