From 5a76fa9a8500d7a8b16e2c65c4d8372000abf6e3 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Sat, 9 Jan 2021 10:10:06 -0500 Subject: [PATCH] Better control over setup.py warnings --- setup.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 86a054ab2..d1bfe6608 100644 --- a/setup.py +++ b/setup.py @@ -14,7 +14,20 @@ from distutils.core import Extension # pylint: disable=wrong-import-order from distutils.command.build_ext import build_ext # pylint: disable=wrong-import-order from distutils import errors # pylint: disable=wrong-import-order - +import distutils.log # pylint: disable=wrong-import-order + +# $set_env.py: COVERAGE_QUIETER - Set to remove some noise from test output. +if bool(int(os.getenv("COVERAGE_QUIETER", "0"))): + # Distutils has its own mini-logging code, and it sets the level too high. + # When I ask for --quiet when running tessts, I don't want to see warnings. + old_set_verbosity = distutils.log.set_verbosity + def better_set_verbosity(v): + """--quiet means no warnings!""" + if v <= 0: + distutils.log.set_threshold(distutils.log.ERROR) + else: + old_set_verbosity(v) + distutils.log.set_verbosity = better_set_verbosity # Get or massage our metadata. We exec coverage/version.py so we can avoid # importing the product code into setup.py.