httpx/tests/utils.py
Florimond Manca 82dc6f32f8 Switch to private module names (#785)
* Rename modules

* Update names in package

* Fix tests

* Review docs
2020-01-28 14:34:43 +00:00

21 lines
463 B
Python

import contextlib
import logging
import os
from httpx import _utils
@contextlib.contextmanager
def override_log_level(log_level: str):
os.environ["HTTPX_LOG_LEVEL"] = log_level
# Force a reload on the logging handlers
_utils._LOGGER_INITIALIZED = False
_utils.get_logger("httpx")
try:
yield
finally:
# Reset the logger so we don't have verbose output in all unit tests
logging.getLogger("httpx").handlers = []