Skip to content

Commit

Permalink
Super-simple implementation of pytest contexts
Browse files Browse the repository at this point in the history
  • Loading branch information
nedbat committed Apr 28, 2019
1 parent 4082617 commit 0c4e1d5
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/pytest_cov/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ def pytest_addoption(parser):
'Default: False')
group.addoption('--cov-branch', action='store_true', default=None,
help='Enable branch coverage.')
group.addoption('--cov-context', action='store_true', default=None,
help='Enable dynamic context collection for each test.')


def _prepare_cov_source(cov_source):
Expand Down Expand Up @@ -300,6 +302,11 @@ def pytest_runtest_call(self, item):
else:
yield

def pytest_runtest_logreport(self, report):
if self.options.cov_context:
context = "{0.nodeid}|{0.outcome}|{0.when}".format(report)
self.cov_controller.cov.switch_context(context)


@pytest.fixture
def no_cover():
Expand Down

0 comments on commit 0c4e1d5

Please sign in to comment.