def collect(self) -> Iterator[None]:
        """A context manager to start/stop coverage measurement collection.

        .. versionadded:: 7.3

        """
        self.start()
        try:
            yield
        finally:
            self.stop()     # pragma: nested
A context manager to start/stop coverage measurement collection.

        .. versionadded:: 7.3

        
coverage/control.py