Merge "Fix various pep8 issues"

This commit is contained in:
Zuul 2017-12-05 18:29:44 +00:00 committed by Gerrit Code Review
commit 62c926edca
4 changed files with 15 additions and 10 deletions

View File

@ -911,8 +911,8 @@ class MethodSignatureChecker(object):
raise ValueError('Could not get argument specification for %r'
% (method,))
if (inspect.ismethod(method) or class_to_bind or (
hasattr(self, '_args') and len(self._args) > 0
and self._args[0] == 'self')):
hasattr(self, '_args') and len(self._args) > 0 and
self._args[0] == 'self')):
self._args = self._args[1:] # Skip 'self'.
self._method = method
self._instance = None # May contain the instance this is bound to.

View File

@ -90,8 +90,8 @@ class StubOutForTesting(object):
# Calling getattr() on a staticmethod transforms it to a 'normal'
# function. We need to ensure that we put it back as a staticmethod.
old_attribute = obj.__dict__.get(attr_name)
if (old_attribute is not None
and isinstance(old_attribute, staticmethod)):
if (old_attribute is not None and
isinstance(old_attribute, staticmethod)):
orig_attr = staticmethod(orig_attr)
self.stubs.append((orig_obj, attr_name, orig_attr))

View File

@ -110,8 +110,12 @@ class FuncTest(testtools.TestCase):
def testFuncTrueFalseEvaluation(self):
"""Should return True if the validating function returns True."""
equals_one = lambda x: x == 1
always_none = lambda x: None
def equals_one(x):
return x == 1
def always_none(x):
return None
self.assertTrue(mox.Func(equals_one) == 1)
self.assertFalse(mox.Func(equals_one) == 0)
@ -210,8 +214,8 @@ class ContainsAttributeValueTest(testtools.TestCase):
def testValidPair(self):
"""Return True if the object has the key attribute that matches."""
self.assertTrue(mox.ContainsAttributeValue("key", 1)
== self.test_object)
self.assertTrue(mox.ContainsAttributeValue("key", 1) ==
self.test_object)
def testInvalidValue(self):
"""Should return False if the value is not correct."""
@ -1257,8 +1261,8 @@ class MockObjectTest(testtools.TestCase):
# NOT doing dummy[index]
dummy._Replay()
function = lambda: [x for x in dummy]
self.assertRaises(mox.UnexpectedMethodCallError, function)
self.assertRaises(mox.UnexpectedMethodCallError,
lambda: [x for x in dummy])
def testMockGetIter_WithSubClassOfNewStyleClass(self):
class NewStyleTestClass(object):

View File

@ -26,4 +26,5 @@ commands =
[flake8]
show-source = true
ignore = E721
exclude=.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg