diff --git a/mox3/mox.py b/mox3/mox.py index 85d4e0c..21e3535 100644 --- a/mox3/mox.py +++ b/mox3/mox.py @@ -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. diff --git a/mox3/stubout.py b/mox3/stubout.py index a02ed40..4773771 100644 --- a/mox3/stubout.py +++ b/mox3/stubout.py @@ -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)) diff --git a/mox3/tests/test_mox.py b/mox3/tests/test_mox.py index 15ac565..0118ab2 100644 --- a/mox3/tests/test_mox.py +++ b/mox3/tests/test_mox.py @@ -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): diff --git a/tox.ini b/tox.ini index 18af8a4..282cea0 100644 --- a/tox.ini +++ b/tox.ini @@ -26,4 +26,5 @@ commands = [flake8] show-source = true +ignore = E721 exclude=.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg