Don't ignore debug logs in pytest, fix log args issue
MODIFY
.github/workflows/ci.yml
.github/workflows/ci.yml
@@ -54,7 +54,7 @@ jobs:
experimental: false
nox-session: test-pypy
- python-version: "2.7"
- os: ubuntu-latest
+ os: ubuntu-20.04 # CPython 2.7 is not available for ubuntu-22.04
experimental: false
nox-session: unsupported_setup_py
- python-version: "3.9"

ADD
changelog/2839.bugfix.rst
+Fix logging error when using ``add_stderr_logger``.

MODIFY
pyproject.toml
pyproject.toml
@@ -81,6 +81,7 @@ include = [
xfail_strict = true
python_classes = ["Test", "*TestCase"]
markers = ["limit_memory"]
+log_level = "DEBUG"
filterwarnings = [
"error",
'''default:'urllib3\[secure\]' extra is deprecated and will be removed in urllib3 v2\.1\.0.*:DeprecationWarning''',

MODIFY
src/urllib3/connectionpool.py
src/urllib3/connectionpool.py
@@ -545,7 +545,7 @@ class HTTPConnectionPool(ConnectionPool, RequestMethods):
response._pool = self # type: ignore[attr-defined]
log.debug(
- '%s://%s:%s "%s %s %s" %s',
+ '%s://%s:%s "%s %s %s" %s %s',
self.scheme,
self.host,
self.port,

MODIFY
test/with_dummyserver/test_connectionpool.py
test/with_dummyserver/test_connectionpool.py
from __future__ import annotations
import io
-import logging
import socket
-import sys
import time
import typing
import warnings
@@ -39,10 +37,6 @@ from ..port_helpers import find_unused_port
pytestmark = pytest.mark.flaky
-log = logging.getLogger("urllib3.connectionpool")
-log.setLevel(logging.NOTSET)
-log.addHandler(logging.StreamHandler(sys.stdout))
-
def wait_for_socket(ready_event: Event) -> None:
ready_event.wait()

MODIFY
test/with_dummyserver/test_https.py
test/with_dummyserver/test_https.py
from __future__ import annotations
import datetime
-import logging
import os.path
import shutil
import ssl
@@ -52,11 +51,6 @@ from .. import has_alpn
pytestmark = pytest.mark.flaky
-log = logging.getLogger("urllib3.connectionpool")
-log.setLevel(logging.NOTSET)
-log.addHandler(logging.StreamHandler(sys.stdout))
-
-
TLSv1_CERTS = DEFAULT_CERTS.copy()
TLSv1_CERTS["ssl_version"] = getattr(ssl, "PROTOCOL_TLSv1", None)

Don't ignore debug logs in pytest, fix log args issue