Skip to content

Commit

Permalink
tests: Filter urllib3 retry warning log messages
Browse files Browse the repository at this point in the history
Some tests like those in tests.cli.test_subcommands assert that there is
no output on stderr.
If urllib3 retries a connection, it logs a warning message which lets
those tests fail.

Signed-off-by: Marcel Bargull <marcel.bargull@udo.edu>
  • Loading branch information
mbargull committed Nov 6, 2023
1 parent b230e5e commit 2ee4b69
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
from logging import getLogger
from pathlib import Path

import pytest
Expand Down Expand Up @@ -66,3 +67,15 @@ def clear_cuda_version():
def do_not_register_envs(monkeypatch):
"""Do not register environments created during tests"""
monkeypatch.setenv("CONDA_REGISTER_ENVS", "false")


@pytest.fixture(autouse=True)
def filter_retry_log_warning():
"""Do not register environments created during tests"""
def log_filter(record):
return not re.match("^Retrying .* after connection broken by", record.msg)

logger = getLogger("urllib3.connectionpool")
logger.addFilter(log_filter)
yield
logger.removeFilter(log_filter)

0 comments on commit 2ee4b69

Please sign in to comment.