def isolate_environment()

in conftest.py [0:0]


def isolate_environment():
    """Ensure any changes to the environment are isolated to individual tests"""
    _environ = os.environ.copy()
    try:
        yield
    finally:
        os.environ.clear()
        os.environ.update(_environ)