Fixes hacking for Py3 tests
bp python3 Change-Id: I7cf367effdf9e3a9fbe3fabc6e59aed98d48335a
This commit is contained in:
parent
a89cec4f88
commit
3578566bf2
@ -126,14 +126,21 @@ class CheckForAssertingNoneEquality(BaseASTChecker):
|
|||||||
# NOTE(dstanek): I wrote this in a verbose way to make it easier to
|
# NOTE(dstanek): I wrote this in a verbose way to make it easier to
|
||||||
# read for those that have little experience with Python's AST.
|
# read for those that have little experience with Python's AST.
|
||||||
|
|
||||||
|
def _is_None(node):
|
||||||
|
if six.PY3:
|
||||||
|
return (isinstance(node, ast.NameConstant)
|
||||||
|
and node.value is None)
|
||||||
|
else:
|
||||||
|
return isinstance(node, ast.Name) and node.id == 'None'
|
||||||
|
|
||||||
if isinstance(node.func, ast.Attribute):
|
if isinstance(node.func, ast.Attribute):
|
||||||
if node.func.attr == 'assertEqual':
|
if node.func.attr == 'assertEqual':
|
||||||
for arg in node.args:
|
for arg in node.args:
|
||||||
if isinstance(arg, ast.Name) and arg.id == 'None':
|
if _is_None(arg):
|
||||||
self.add_error(node, message=self.CHECK_DESC_IS)
|
self.add_error(node, message=self.CHECK_DESC_IS)
|
||||||
elif node.func.attr == 'assertNotEqual':
|
elif node.func.attr == 'assertNotEqual':
|
||||||
for arg in node.args:
|
for arg in node.args:
|
||||||
if isinstance(arg, ast.Name) and arg.id == 'None':
|
if _is_None(arg):
|
||||||
self.add_error(node, message=self.CHECK_DESC_ISNOT)
|
self.add_error(node, message=self.CHECK_DESC_ISNOT)
|
||||||
|
|
||||||
super(CheckForAssertingNoneEquality, self).generic_visit(node)
|
super(CheckForAssertingNoneEquality, self).generic_visit(node)
|
||||||
@ -391,10 +398,14 @@ class CheckForLoggingIssues(BaseASTChecker):
|
|||||||
peers = find_peers(node)
|
peers = find_peers(node)
|
||||||
for peer in peers:
|
for peer in peers:
|
||||||
if isinstance(peer, ast.Raise):
|
if isinstance(peer, ast.Raise):
|
||||||
if (isinstance(peer.type, ast.Call) and
|
if six.PY3:
|
||||||
len(peer.type.args) > 0 and
|
exc = peer.exc
|
||||||
isinstance(peer.type.args[0], ast.Name) and
|
else:
|
||||||
name in (a.id for a in peer.type.args)):
|
exc = peer.type
|
||||||
|
if (isinstance(exc, ast.Call) and
|
||||||
|
len(exc.args) > 0 and
|
||||||
|
isinstance(exc.args[0], ast.Name) and
|
||||||
|
name in (a.id for a in exc.args)):
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
@ -3,7 +3,6 @@ keystone.tests.unit.common.test_notifications
|
|||||||
keystone.tests.unit.test_associate_project_endpoint_extension
|
keystone.tests.unit.test_associate_project_endpoint_extension
|
||||||
keystone.tests.unit.test_backend_ldap
|
keystone.tests.unit.test_backend_ldap
|
||||||
keystone.tests.unit.test_backend_ldap_pool
|
keystone.tests.unit.test_backend_ldap_pool
|
||||||
keystone.tests.unit.test_hacking_checks
|
|
||||||
keystone.tests.unit.test_ipv6
|
keystone.tests.unit.test_ipv6
|
||||||
keystone.tests.unit.test_v2
|
keystone.tests.unit.test_v2
|
||||||
keystone.tests.unit.test_v3
|
keystone.tests.unit.test_v3
|
||||||
|
Loading…
Reference in New Issue
Block a user