Merge "Remove checks for Python 2/3 compatibility"
This commit is contained in:
@@ -9,9 +9,6 @@ Heat Specific Commandments
|
||||
--------------------------
|
||||
|
||||
- [HE301] Use LOG.warning() rather than LOG.warn().
|
||||
- [HE302] Python 3: do not use dict.iteritems.
|
||||
- [HE303] Python 3: do not use dict.iterkeys.
|
||||
- [HE304] Python 3: do not use dict.itervalues.
|
||||
|
||||
Creating unit tests
|
||||
-------------------
|
||||
|
||||
@@ -13,8 +13,6 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import re
|
||||
|
||||
from hacking import core
|
||||
|
||||
|
||||
@@ -43,27 +41,3 @@ def no_log_warn(logical_line):
|
||||
"""
|
||||
if logical_line.startswith('LOG.warn('):
|
||||
yield (0, 'HE301 Use LOG.warning() rather than LOG.warn()')
|
||||
|
||||
|
||||
@core.flake8ext
|
||||
def check_python3_no_iteritems(logical_line):
|
||||
msg = ("HE302: Use dict.items() instead of dict.iteritems().")
|
||||
|
||||
if re.search(r".*\.iteritems\(\)", logical_line):
|
||||
yield (0, msg)
|
||||
|
||||
|
||||
@core.flake8ext
|
||||
def check_python3_no_iterkeys(logical_line):
|
||||
msg = ("HE303: Use dict.keys() instead of dict.iterkeys().")
|
||||
|
||||
if re.search(r".*\.iterkeys\(\)", logical_line):
|
||||
yield (0, msg)
|
||||
|
||||
|
||||
@core.flake8ext
|
||||
def check_python3_no_itervalues(logical_line):
|
||||
msg = ("HE304: Use dict.values() instead of dict.itervalues().")
|
||||
|
||||
if re.search(r".*\.itervalues\(\)", logical_line):
|
||||
yield (0, msg)
|
||||
|
||||
@@ -17,32 +17,9 @@ from heat.tests import common
|
||||
|
||||
|
||||
class HackingTestCase(common.HeatTestCase):
|
||||
def test_dict_iteritems(self):
|
||||
self.assertEqual(1, len(list(checks.check_python3_no_iteritems(
|
||||
"obj.iteritems()"))))
|
||||
def test_log_warn(self):
|
||||
self.assertEqual(1, len(list(checks.no_log_warn(
|
||||
"LOG.warn('bad')"))))
|
||||
|
||||
self.assertEqual(0, len(list(checks.check_python3_no_iteritems(
|
||||
"obj.items()"))))
|
||||
|
||||
self.assertEqual(0, len(list(checks.check_python3_no_iteritems(
|
||||
"obj.items()"))))
|
||||
|
||||
def test_dict_iterkeys(self):
|
||||
self.assertEqual(1, len(list(checks.check_python3_no_iterkeys(
|
||||
"obj.iterkeys()"))))
|
||||
|
||||
self.assertEqual(0, len(list(checks.check_python3_no_iterkeys(
|
||||
"obj.keys()"))))
|
||||
|
||||
self.assertEqual(0, len(list(checks.check_python3_no_iterkeys(
|
||||
"obj.keys()"))))
|
||||
|
||||
def test_dict_itervalues(self):
|
||||
self.assertEqual(1, len(list(checks.check_python3_no_itervalues(
|
||||
"obj.itervalues()"))))
|
||||
|
||||
self.assertEqual(0, len(list(checks.check_python3_no_itervalues(
|
||||
"obj.values()"))))
|
||||
|
||||
self.assertEqual(0, len(list(checks.check_python3_no_itervalues(
|
||||
"obj.values()"))))
|
||||
self.assertEqual(0, len(list(checks.no_log_warn(
|
||||
"LOG.warning('bad')"))))
|
||||
|
||||
3
tox.ini
3
tox.ini
@@ -99,9 +99,6 @@ import_exceptions = heat.common.i18n
|
||||
[flake8:local-plugins]
|
||||
extension =
|
||||
HE301 = checks:no_log_warn
|
||||
HE302 = checks:check_python3_no_iteritems
|
||||
HE303 = checks:check_python3_no_iterkeys
|
||||
HE304 = checks:check_python3_no_itervalues
|
||||
paths = ./heat/hacking
|
||||
|
||||
[testenv:debug]
|
||||
|
||||
Reference in New Issue
Block a user