Skip to content

Commit 77dc37f

Browse files
committed
Tweak some coverage details of switch_context code
1 parent cecc5dd commit 77dc37f

File tree

3 files changed

+3
-6
lines changed

3 files changed

+3
-6
lines changed

coverage/collector.py

-4
Original file line numberDiff line numberDiff line change
@@ -256,10 +256,6 @@ def _start_tracer(self):
256256
if hasattr(tracer, 'should_start_context'):
257257
tracer.should_start_context = self.should_start_context
258258
tracer.switch_context = self.switch_context
259-
elif self.should_start_context:
260-
raise CoverageException(
261-
"Can't support dynamic contexts with {}".format(self.tracer_name())
262-
)
263259

264260
fn = tracer.start()
265261
self.tracers.append(tracer)

coverage/control.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -561,8 +561,8 @@ def switch_context(self, new_context):
561561
.. versionadded:: 5.0
562562
563563
"""
564-
if not self._started:
565-
raise CoverageException( # pragma: only jython
564+
if not self._started: # pragma: part started
565+
raise CoverageException(
566566
"Cannot switch context, coverage is not started"
567567
)
568568
self._collector.switch_context(new_context)

metacov.ini

+1
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ exclude_lines =
7171
partial_branches =
7272
pragma: part covered
7373
pragma: if failure
74+
pragma: part started
7475
if env.TESTING:
7576
if .* env.JYTHON
7677
if .* env.IRONPYTHON

0 commit comments

Comments
 (0)