Merge "Replace warning.warn with LOG.warning"

This commit is contained in:
Jenkins 2016-10-11 16:02:37 +00:00 committed by Gerrit Code Review
commit 2d533be500
4 changed files with 11 additions and 9 deletions

View File

@ -13,12 +13,14 @@
# License for the specific language governing permissions and limitations
# under the License.
from rally.common import logging
from rally.common.objects import credential
LOG = logging.getLogger(__name__)
class Endpoint(credential.Credential):
def __init__(self, *args, **kwargs):
super(Endpoint, self).__init__(*args, **kwargs)
import warnings # import this library only when it required
warnings.warn("Endpoint is deprecated since Rally 0.1.2. "
"Please use rally.common.objects.credentials instead")
LOG.warning("Endpoint is deprecated since Rally 0.1.2. "
"Please use rally.common.objects.credentials instead")

View File

@ -20,12 +20,14 @@ from six.moves.urllib import parse
from rally.cli import envutils
from rally.common.i18n import _
from rally.common import logging
from rally.common import objects
from rally.common.plugin import plugin
from rally import consts
from rally import exceptions
LOG = logging.getLogger(__name__)
CONF = cfg.CONF
OSCLIENTS_OPTS = [
@ -147,8 +149,7 @@ class OSClient(plugin.Plugin):
self.cache)
def _get_session(self, auth_url=None, version=None):
import warnings
warnings.warn(
LOG.warning(
"Method `rally.osclient.OSClient._get_session` is deprecated since"
" Rally 0.6.0. Use "
"`rally.osclient.OSClient.keystone.get_session` instead.")

View File

@ -100,6 +100,5 @@ class DeprecatedFileExporter(FileExporter):
"""DEPRECATED."""
def __init__(self, connection_string):
super(DeprecatedFileExporter, self).__init__(connection_string)
import warnings
warnings.warn("'file-exporter' plugin is deprecated. Use 'file' "
"instead.")
LOG.warning("'file-exporter' plugin is deprecated. Use 'file' "
"instead.")

View File

@ -117,7 +117,7 @@ class OSClientTestCase(test.TestCase, OSClientTestCaseUtils):
with mock.patch.object(warnings, "warn") as mock_warn:
self.assertEqual(mock_keystone_get_session.return_value,
osclient._get_session(auth_url, version))
self.assertTrue(mock_warn.called)
self.assertFalse(mock_warn.called)
mock_keystone_get_session.assert_called_once_with(version)