Browse Source

Fix various pep8 issues

There weren't called before because test-requirements
hardcoded an older version that is not what flake8 expected.

Change-Id: I43b0c9f89d8411ae536ffd0540ff7ba47df46dda
Dirk Mueller 1 year ago
parent
commit
391d7c38f5
4 changed files with 15 additions and 10 deletions
  1. 2
    2
      mox3/mox.py
  2. 2
    2
      mox3/stubout.py
  3. 10
    6
      mox3/tests/test_mox.py
  4. 1
    0
      tox.ini

+ 2
- 2
mox3/mox.py View File

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

+ 2
- 2
mox3/stubout.py View File

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

+ 10
- 6
mox3/tests/test_mox.py View File

@@ -110,8 +110,12 @@ class FuncTest(testtools.TestCase):
110 110
 
111 111
     def testFuncTrueFalseEvaluation(self):
112 112
         """Should return True if the validating function returns True."""
113
-        equals_one = lambda x: x == 1
114
-        always_none = lambda x: None
113
+
114
+        def equals_one(x):
115
+            return x == 1
116
+
117
+        def always_none(x):
118
+            return None
115 119
 
116 120
         self.assertTrue(mox.Func(equals_one) == 1)
117 121
         self.assertFalse(mox.Func(equals_one) == 0)
@@ -210,8 +214,8 @@ class ContainsAttributeValueTest(testtools.TestCase):
210 214
 
211 215
     def testValidPair(self):
212 216
         """Return True if the object has the key attribute that matches."""
213
-        self.assertTrue(mox.ContainsAttributeValue("key", 1)
214
-                        == self.test_object)
217
+        self.assertTrue(mox.ContainsAttributeValue("key", 1) ==
218
+                        self.test_object)
215 219
 
216 220
     def testInvalidValue(self):
217 221
         """Should return False if the value is not correct."""
@@ -1257,8 +1261,8 @@ class MockObjectTest(testtools.TestCase):
1257 1261
         # NOT doing dummy[index]
1258 1262
 
1259 1263
         dummy._Replay()
1260
-        function = lambda: [x for x in dummy]
1261
-        self.assertRaises(mox.UnexpectedMethodCallError, function)
1264
+        self.assertRaises(mox.UnexpectedMethodCallError,
1265
+                          lambda: [x for x in dummy])
1262 1266
 
1263 1267
     def testMockGetIter_WithSubClassOfNewStyleClass(self):
1264 1268
         class NewStyleTestClass(object):

+ 1
- 0
tox.ini View File

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

Loading…
Cancel
Save