I would use patch.dict to patch os.environ, see the example in
http://www.voidspace.org.uk/python/mock/patch.html#patch-dict

(the advantage is that it performs a try..finally and the variable is reset even in case of errors)