mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
Fix mulled tests missing tests in `test/unit/tool_util/test_conda_resolution.py` . Also: - Add `coverage` tox factor to generate coverage report.
27 lines
715 B
Python
27 lines
715 B
Python
from contextlib import contextmanager
|
|
from os import environ
|
|
|
|
import pytest
|
|
|
|
external_dependency_management = pytest.mark.external_dependency_management
|
|
|
|
|
|
@contextmanager
|
|
def modify_environ(values, keys_to_remove=None):
|
|
"""
|
|
Modify the environment for a test, adding/updating values in dict `values` and
|
|
removing any environment variables mentioned in list `keys_to_remove`.
|
|
"""
|
|
old_environ = environ.copy()
|
|
try:
|
|
if values:
|
|
environ.update(values)
|
|
if keys_to_remove:
|
|
for key in keys_to_remove:
|
|
if key in environ:
|
|
del environ[key]
|
|
yield
|
|
finally:
|
|
environ.clear()
|
|
environ.update(old_environ)
|