Exemplo n.º 1
0
class CoveragePlugin:
    """The py.test coverage plugin."""
    def __init__(self, config):
        self.config = config

    def pytest_sessionstart(self):
        """Called before session.main() is called."""
        self.coverage = CoverageTestWrapper(self.config.option)
        # XXX maybe better to start/suspend/resume coverage
        # for each single test item
        self.coverage.start()

    def pytest_terminal_summary(self, terminalreporter):
        """Add an additional section in the terminal summary reporting."""
        tw = terminalreporter._tw
        tw.sep('-', 'coverage')
        tw.line('Processing Coverage...')
        self.coverage.finish()
Exemplo n.º 2
0
class CoveragePlugin:
    """The py.test coverage plugin."""

    def __init__(self, config):
        self.config = config

    def pytest_sessionstart(self):
        """Called before session.main() is called."""
        self.coverage = CoverageTestWrapper(self.config.option)
        # XXX maybe better to start/suspend/resume coverage
        # for each single test item
        self.coverage.start()

    def pytest_terminal_summary(self, terminalreporter):
        """Add an additional section in the terminal summary reporting."""
        tw = terminalreporter._tw
        tw.sep('-', 'coverage')
        tw.line('Processing Coverage...')
        self.coverage.finish()
Exemplo n.º 3
0
class Coverage(Plugin):
    """The nose plugin to measure test coverage."""

    score = 200
    status = {}

    config = opts = coverage = None

    def help(self):
        """The help for the --with-coverage option."""
        return "Measure test coverage using coverage.py."

    def options(self, parser, env):
        """Add command-line options."""
        super(Coverage, self).options(parser, env)
        for opt in OPTIONS:
            parser.add_option(opt)

    def configure(self, options, config):
        """Configure plugin."""
        try:
            self.status.pop('active')
        except KeyError:
            pass

        super(Coverage, self).configure(options, config)

        self.config = config
        self.status['active'] = True
        self.opts = options

    def begin(self):
        """Begin recording coverage information."""
        log.debug("Coverage begin")
        self.coverage = CoverageTestWrapper(self.opts)
        self.coverage.start()

    def report(self, stream):
        """Output code coverage report."""
        log.debug("Coverage report")
        stream.write("Processing coverage...\n")
        self.coverage.finish(stream)
Exemplo n.º 4
0
class Coverage(Plugin):
    """The nose plugin to measure test coverage."""

    score = 200
    status = {}

    config = opts = coverage = None

    def help(self):
        """The help for the --with-coverage option."""
        return "Measure test coverage using coverage.py."

    def options(self, parser, env):
        """Add command-line options."""
        super(Coverage, self).options(parser, env)
        for opt in OPTIONS:
            parser.add_option(opt)

    def configure(self, options, config):
        """Configure plugin."""
        try:
            self.status.pop('active')
        except KeyError:
            pass

        super(Coverage, self).configure(options, config)

        self.config = config
        self.status['active'] = True
        self.opts = options

    def begin(self):
        """Begin recording coverage information."""
        log.debug("Coverage begin")
        self.coverage = CoverageTestWrapper(self.opts)
        self.coverage.start()

    def report(self, stream):
        """Output code coverage report."""
        log.debug("Coverage report")
        stream.write("Processing coverage...\n")
        self.coverage.finish(stream)