Merge "Refactor oslo.foo as oslo_foo"

This commit is contained in:
Jenkins
2015-01-26 12:33:32 +00:00
committed by Gerrit Code Review
4 changed files with 36 additions and 1 deletions

View File

@@ -32,3 +32,4 @@ Rally Specific Commandments
* [N337] - Ensure that ``next()`` method on iterator objects is not used
* [N338] - Ensure that ``+`` operand is not used to concatenate dict.items()
* [N340] - Ensure that we are importing always ``from rally import objects``
* [N341] - Ensure that we are importing oslo_xyz packages instead of deprecated oslo.xyz ones

View File

@@ -379,6 +379,21 @@ def check_no_direct_rally_objects_import(logical_line, filename):
"After that you can use directly objects e.g. objects.Task")
def check_no_oslo_deprecated_import(logical_line, filename):
"""Check if oslo.foo packages are not imported instead of oslo_foo ones.
Libraries from oslo.foo namespace are deprecated because of namespace
problems.
N341
"""
if (logical_line.startswith("from oslo.")
or logical_line.startswith("import oslo.")):
yield (0, "N341: Import oslo module: `from oslo_xyz import ...`. "
"The oslo.xyz namespace was deprecated, use oslo_xyz "
"instead")
def factory(register):
register(check_assert_methods_from_mock)
register(check_import_of_logging)
@@ -399,3 +414,4 @@ def factory(register):
register(check_next_on_iterator_method)
register(check_no_direct_rally_objects_import)
register(check_concatenate_dict_with_plus_operand)
register(check_no_oslo_deprecated_import)

View File

@@ -16,7 +16,7 @@
import os
import mock
from oslo.config import fixture
from oslo_config import fixture
from oslotest import base
from rally import db

View File

@@ -347,3 +347,21 @@ class HackingTestCase(test.TestCase):
checkres = checks.check_no_direct_rally_objects_import(good_import,
"fakefile")
self.assertEqual([], list(checkres))
def test_check_no_oslo_deprecated_import(self):
bad_imports = ["from oslo.config",
"import oslo.config,"
"from oslo.db",
"import oslo.db,"
"from oslo.i18n",
"import oslo.i18n,"
"from oslo.serialization",
"import oslo.serialization,"
"from oslo.utils",
"import oslo.utils,"]
for bad_import in bad_imports:
checkres = checks.check_no_oslo_deprecated_import(bad_import,
"fakefile")
self.assertIsNotNone(next(checkres))