From 9a0f9e19ba43887d53fdc53f015f00148e9ba2b9 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Sun, 23 Sep 2018 20:21:42 -0400 Subject: Make static and dynamic contexts work together --- coverage/collector.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'coverage/collector.py') diff --git a/coverage/collector.py b/coverage/collector.py index 686d4a7e..4e7058a0 100644 --- a/coverage/collector.py +++ b/coverage/collector.py @@ -373,7 +373,13 @@ class Collector(object): def switch_context(self, new_context): """Switch to a new dynamic context.""" self.flush_data() - self.covdata.set_context(new_context) + if self.static_context: + context = self.static_context + if new_context: + context += ":" + new_context + else: + context = new_context + self.covdata.set_context(context) def cached_abs_file(self, filename): """A locally cached version of `abs_file`.""" -- cgit v1.2.1