From 336aca762bf93e17261df94a3aae038192b825b1 Mon Sep 17 00:00:00 2001 From: Tin Lam Date: Mon, 7 Mar 2016 18:51:44 -0600 Subject: [PATCH] Removed deprecation warning from 'tempest --help' Deprecation warning of stress test runner should not show up when running 'tempest --help'. Warning show be shown only when we run the stress command. Change-Id: I6135559b6103f56542b611074ec81d29091e40b5 Closes-Bug: #1552863 --- tempest/cmd/run_stress.py | 12 ++++++++++++ tempest/stress/__init__.py | 22 ---------------------- 2 files changed, 12 insertions(+), 22 deletions(-) mode change 100644 => 100755 tempest/cmd/run_stress.py diff --git a/tempest/cmd/run_stress.py b/tempest/cmd/run_stress.py old mode 100644 new mode 100755 index 6fe3928172..9c8552f92a --- a/tempest/cmd/run_stress.py +++ b/tempest/cmd/run_stress.py @@ -23,6 +23,7 @@ except ImportError: # unittest in python 2.6 does not contain loader, so uses unittest2 from unittest2 import loader import traceback +import warnings from cliff import command from oslo_log import log as logging @@ -74,7 +75,17 @@ def discover_stress_tests(path="./", filter_attr=None, call_inherited=False): class TempestRunStress(command.Command): + @staticmethod + def display_deprecation_warning(): + warnings.simplefilter('once', category=DeprecationWarning) + warnings.warn( + 'Stress tests are deprecated and will be removed from Tempest ' + 'in the Newton release.', + DeprecationWarning) + warnings.resetwarnings() + def get_parser(self, prog_name): + self.display_deprecation_warning() pa = super(TempestRunStress, self).get_parser(prog_name) pa = add_arguments(pa) return pa @@ -146,6 +157,7 @@ def action(ns): def main(): + TempestRunStress.display_deprecation_warning() parser = argparse.ArgumentParser(description='Run stress tests') pa = add_arguments(parser) ns = pa.parse_args() diff --git a/tempest/stress/__init__.py b/tempest/stress/__init__.py index 987a023b30..e69de29bb2 100644 --- a/tempest/stress/__init__.py +++ b/tempest/stress/__init__.py @@ -1,22 +0,0 @@ -# Copyright 2016 NEC Corporation. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import warnings - -warnings.simplefilter('once', category=DeprecationWarning) -warnings.warn( - 'Stress tests are deprecated and will be removed from Tempest ' - 'in the Newton release.', - DeprecationWarning) -warnings.resetwarnings()