Skip to content
Myr

utils.py

This file

Path

tests/utils.py

21 lines · 502 bytes · Python

Last changed by

Typing: enable disallow_incomplete_defs (#2476)Martijn Pietersbefore adoption049afe5

History of this file

Take it

1import contextlib2import logging3import os4import typing56from httpx import _utils789@contextlib.contextmanager10def override_log_level(log_level: str) -> typing.Iterator[None]:11    os.environ["HTTPX_LOG_LEVEL"] = log_level1213    # Force a reload on the logging handlers14    _utils._LOGGER_INITIALIZED = False15    _utils.get_logger("httpx")1617    try:18        yield19    finally:20        # Reset the logger so we don't have verbose output in all unit tests21        logging.getLogger("httpx").handlers = []