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 2d39c0d point at it.
Docs: list CURL_CA_BUNDLE as supported (#5509)Ben Bodenmillerbefore adoption2d39c0d
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)