utils.py
This file
Path
tests/utils.py
17 lines · 366 bytes · Python
Last changed by
Add automatic code formatting to Requests (#6095)Nate Prewittbefore adoption2a6f290
History of this fileTake it
The walk stopped after 200 commits: lines older than 56fd46f point at it.
Merge pull request #5243 from hugovk/test-3.8-finalNate Prewittbefore adoption56fd46f
lines 1–17why, one step back1import contextlib2import os345@contextlib.contextmanager6def override_environ(**kwargs):7 save_env = dict(os.environ)8 for key, value in kwargs.items():9 if value is None:10 del os.environ[key]11 else:12 os.environ[key] = value13 try:14 yield15 finally:16 os.environ.clear()17 os.environ.update(save_env)