def ensure_context_manager():
     before()
     with modified_environ(**kwargs):
         during()
     after()
예제 #2
0
import os
from pollute import modified_environ


assert 'HELLO' not in os.environ
assert 'PATH' in os.environ

with modified_environ(added={'HELLO': 'WORLD'}, absent=['PATH']):
    assert os.environ['HELLO'] == 'WORLD'
    assert 'PATH' not in os.environ

assert 'HELLO' not in os.environ
assert 'PATH' in os.environ
예제 #3
0
import os
from pollute import modified_environ

assert 'HELLO' not in os.environ
assert 'PATH' in os.environ

with modified_environ(added={'HELLO': 'WORLD'}, absent=['PATH']):
    assert os.environ['HELLO'] == 'WORLD'
    assert 'PATH' not in os.environ

assert 'HELLO' not in os.environ
assert 'PATH' in os.environ
예제 #4
0
파일: env.py 프로젝트: wangyiyanan/ats.aic
def environment(added=None, absent=()):
    """Context manager that modifies the environments variables.
    Path objects as values are replaced with strings.
    """
    added = stringify_dict(added or {})
    return pollute.modified_environ(added, absent)
 def ensure_context_manager():
     before()
     with modified_environ(**kwargs):
         during()
     after()