From 987ceb9300c9326e4932dd69d633e7bd7be04e16 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Sun, 13 Sep 2020 13:30:20 -0400 Subject: Fix a missed exception handling for bad plugins --- tests/test_plugins.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'tests') diff --git a/tests/test_plugins.py b/tests/test_plugins.py index 2477f5ce..ed58c5f4 100644 --- a/tests/test_plugins.py +++ b/tests/test_plugins.py @@ -804,6 +804,28 @@ class BadFileTracerTest(FileTracerTest): """) self.run_bad_plugin("bad_plugin", "Plugin") + def test_line_number_range_raises_error(self): + self.make_file("bad_plugin.py", """\ + import coverage.plugin + class Plugin(coverage.plugin.CoveragePlugin): + def file_tracer(self, filename): + if filename.endswith("other.py"): + return BadFileTracer() + + class BadFileTracer(coverage.plugin.FileTracer): + def source_filename(self): + return "something.foo" + + def line_number_range(self, frame): + raise Exception("borked!") + + def coverage_init(reg, options): + reg.add_file_tracer(Plugin()) + """) + self.run_bad_plugin( + "bad_plugin", "Plugin", our_error=False, excmsg="borked!", + ) + def test_line_number_range_returns_non_tuple(self): self.make_file("bad_plugin.py", """\ import coverage.plugin -- cgit v1.2.1