@pytest.fixture(scope='function')
def environ():
    'py.test fixture to get a fresh mutable environment.'
    old_env = os.environ
    new_env = dict(list(old_env.items()))
    os.environ = new_env
    (yield os.environ)
    os.environ = old_env
py.test fixture to get a fresh mutable environment.
@pytest.fixture(scope='function')
def environ():
    
    old_env = os.environ
    new_env = dict(list(old_env.items()))
    os.environ = new_env
    (yield os.environ)
    os.environ = old_env