Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/pytest_cov/embed.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ def init():
cov_config = os.environ.get('COV_CORE_CONFIG')
cov_datafile = os.environ.get('COV_CORE_DATAFILE')
cov_branch = True if os.environ.get('COV_CORE_BRANCH') == 'enabled' else None
cov_context = os.environ.get('COV_CORE_CONTEXT')

if cov_datafile:
if _active_cov:
Expand All @@ -71,6 +72,8 @@ def init():
)
cov.load()
cov.start()
if cov_context:
cov.switch_context(cov_context)
cov._warn_no_data = False
cov._warn_unimported_source = False
return cov
Expand Down
1 change: 1 addition & 0 deletions src/pytest_cov/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ def unset_env():
os.environ.pop('COV_CORE_CONFIG', None)
os.environ.pop('COV_CORE_DATAFILE', None)
os.environ.pop('COV_CORE_BRANCH', None)
os.environ.pop('COV_CORE_CONTEXT', None)

@staticmethod
def get_node_desc(platform, version_info):
Expand Down
1 change: 1 addition & 0 deletions src/pytest_cov/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,7 @@ def pytest_runtest_call(self, item):
def switch_context(self, item, when):
context = "{item.nodeid}|{when}".format(item=item, when=when)
self.cov.switch_context(context)
os.environ['COV_CORE_CONTEXT'] = context


@pytest.fixture
Expand Down