Skip to content

Commit

Permalink
Add simple regression test for logging patches
Browse files Browse the repository at this point in the history
  • Loading branch information
abravalheri committed Nov 23, 2022
1 parent bd60014 commit 7049c73
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions setuptools/tests/test_logging.py
@@ -1,4 +1,6 @@
import inspect
import logging
import os

import pytest

Expand Down Expand Up @@ -34,3 +36,18 @@ def test_verbosity_level(tmp_path, monkeypatch, flag, expected_level):
log_level = logger.getEffectiveLevel()
log_level_name = logging.getLevelName(log_level)
assert log_level_name == expected_level


def test_patching_does_not_cause_problems():
# Ensure `dist.log` is only patched if necessary

import setuptools.logging
from distutils import dist # <- load distutils after all the patches take place

setuptools.logging.configure()

if os.getenv("SETUPTOOLS_USE_DISTUTILS", "local").lower() == "local":
# Modern logging infra, no problematic patching.
assert isinstance(dist.log, logging.Logger)
else:
assert inspect.ismodule(dist.log)

0 comments on commit 7049c73

Please sign in to comment.