From 194b08884fe9281a79734f2d6e31013a627ba4da Mon Sep 17 00:00:00 2001 From: Slawek Kaplonski Date: Thu, 18 Mar 2021 21:50:19 +0100 Subject: [PATCH] Log python warnings only once to limit size of CI jobs' output This patch sets to log python warnings only once in the tests and also sets some of the oslo_context warnings, related to the policy enforcement to be ignored to limit size of the output of e.g. unit tests jobs. Change-Id: I28d8a193198bbc4249cf7a37d70f065efd908c41 --- neutron/tests/base.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/neutron/tests/base.py b/neutron/tests/base.py index 1fe65f8861b..14aa07a77ff 100644 --- a/neutron/tests/base.py +++ b/neutron/tests/base.py @@ -26,6 +26,7 @@ import os.path import queue import threading from unittest import mock +import warnings import eventlet.timeout import fixtures @@ -226,6 +227,17 @@ class DietTestCase(base.BaseTestCase, metaclass=_CatchTimeoutMetaclass): def setUp(self): super(DietTestCase, self).setUp() + # NOTE(slaweq): Make deprecation warnings only happen once. + warnings.simplefilter("once", DeprecationWarning) + + # NOTE(slaweq): Let's not display such warnings in tests as we know + # that we have many places where policy enforcement depends on values + # like is_admin or project_id and there can be a lot of such warnings + # in the logs + warnings.filterwarnings( + 'ignore', message=( + 'Policy enforcement is depending on the value of ')) + # Suppress some log messages during test runs, otherwise it may cause # issues with subunit parser when running on Python 3. It happened for # example for neutron-functional tests.