Skip to content

Instantly share code, notes, and snippets.

@jezdez
Created July 2, 2012 17:42
Show Gist options
  • Save jezdez/3034518 to your computer and use it in GitHub Desktop.
Save jezdez/3034518 to your computer and use it in GitHub Desktop.
from functools import wraps
from mock import patch
def environ(**variables):
def decorator(func):
@wraps(func)
def wrapped(*args, **kwargs):
with patch.dict('os.environ', variables):
return func(*args, **kwargs)
return wrapped
return decorator
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment