From 22df523291e6b5a2fc42ffc0ed074635c493629c Mon Sep 17 00:00:00 2001 From: Radomir Dopieralski Date: Mon, 9 Jun 2014 09:12:43 +0200 Subject: [PATCH] Silence the deprecation warning about with statements The tests use contextlib.nested for nesting multiple with statements, but that function generates a warning in python 2.7 telling us, that there is a better syntax for it. Unfortunately, we need to support older python versions, so we can't use that new syntax. The warning is annoying, as it clobbers the output of tests and makes other warnings harder to see. This patch silences that warning in tests. Change-Id: I6e49faad4c45c13ee2e0041fe9d31b7fcd3670a6 --- tuskar_ui/test/helpers.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tuskar_ui/test/helpers.py b/tuskar_ui/test/helpers.py index 144e60b07..87be6f0d1 100644 --- a/tuskar_ui/test/helpers.py +++ b/tuskar_ui/test/helpers.py @@ -12,6 +12,7 @@ # under the License. import os +import warnings from django.core.handlers import wsgi from django.utils import unittest @@ -23,6 +24,11 @@ from tuskar_ui.test.test_data import utils as test_data_utils # Makes output of failing mox tests much easier to read. wsgi.WSGIRequest.__repr__ = lambda self: "" +# Silences the warning about with statements. +warnings.filterwarnings('ignore', 'With-statements now directly support ' + 'multiple context managers', DeprecationWarning, + r'^tuskar_ui[.].*[._]tests$') + def create_stubs(stubs_to_create={}): return openstack_dashboard_helpers.create_stubs(stubs_to_create)