summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndras Tim <andras.tim@gmail.com>2017-07-17 01:25:10 +0200
committerAndras Tim <andras.tim@gmail.com>2017-07-17 01:44:23 +0200
commitb49e8baab3759d70d4af138d76cf28321f3e7807 (patch)
tree12fcb534e7bf171b072e0b9caf746fca912d7ed9
parent15610289ac720bbdd90c5b69b6a5ef6405a2c4ab (diff)
downloadpytest-b49e8baab3759d70d4af138d76cf28321f3e7807.tar.gz
Fixed E731 flake8 errors
do not assign a lambda expression, use a def
-rw-r--r--_pytest/_code/source.py3
-rw-r--r--_pytest/assertion/rewrite.py3
-rw-r--r--_pytest/assertion/util.py16
-rw-r--r--_pytest/python.py8
-rw-r--r--testing/test_session.py5
-rw-r--r--tox.ini1
6 files changed, 25 insertions, 11 deletions
diff --git a/_pytest/_code/source.py b/_pytest/_code/source.py
index 2ee1c317e..e21fecb1e 100644
--- a/_pytest/_code/source.py
+++ b/_pytest/_code/source.py
@@ -136,7 +136,8 @@ class Source(object):
try:
import parser
except ImportError:
- syntax_checker = lambda x: compile(x, 'asd', 'exec')
+ def syntax_checker(x):
+ return compile(x, 'asd', 'exec')
else:
syntax_checker = parser.suite
diff --git a/_pytest/assertion/rewrite.py b/_pytest/assertion/rewrite.py
index 97663ccda..992002b81 100644
--- a/_pytest/assertion/rewrite.py
+++ b/_pytest/assertion/rewrite.py
@@ -39,7 +39,8 @@ ASCII_IS_DEFAULT_ENCODING = sys.version_info[0] < 3
if sys.version_info >= (3, 5):
ast_Call = ast.Call
else:
- ast_Call = lambda a, b, c: ast.Call(a, b, c, None, None)
+ def ast_Call(a, b, c):
+ return ast.Call(a, b, c, None, None)
class AssertionRewritingHook(object):
diff --git a/_pytest/assertion/util.py b/_pytest/assertion/util.py
index c2a5ddee0..41e66448d 100644
--- a/_pytest/assertion/util.py
+++ b/_pytest/assertion/util.py
@@ -111,11 +111,17 @@ def assertrepr_compare(config, op, left, right):
summary = u('%s %s %s') % (ecu(left_repr), op, ecu(right_repr))
- issequence = lambda x: (isinstance(x, (list, tuple, Sequence)) and
- not isinstance(x, basestring))
- istext = lambda x: isinstance(x, basestring)
- isdict = lambda x: isinstance(x, dict)
- isset = lambda x: isinstance(x, (set, frozenset))
+ def issequence(x):
+ return (isinstance(x, (list, tuple, Sequence)) and not isinstance(x, basestring))
+
+ def istext(x):
+ return isinstance(x, basestring)
+
+ def isdict(x):
+ return isinstance(x, dict)
+
+ def isset(x):
+ return isinstance(x, (set, frozenset))
def isiterable(obj):
try:
diff --git a/_pytest/python.py b/_pytest/python.py
index 47759ecee..5b0ebe240 100644
--- a/_pytest/python.py
+++ b/_pytest/python.py
@@ -1415,7 +1415,10 @@ class approx(object):
# or a sequence of numbers, return a list of ApproxNotIterable objects
# that can be compared against.
from collections import Iterable
- approx_non_iter = lambda x: ApproxNonIterable(x, self.rel, self.abs)
+
+ def approx_non_iter(x):
+ return ApproxNonIterable(x, self.rel, self.abs)
+
if isinstance(self._expected, Iterable):
return [approx_non_iter(x) for x in self._expected]
else:
@@ -1489,7 +1492,8 @@ class ApproxNonIterable(object):
@property
def tolerance(self):
- set_default = lambda x, default: x if x is not None else default
+ def set_default(x, default):
+ return x if x is not None else default
# Figure out what the absolute tolerance should be. ``self.abs`` is
# either None or a value specified by the user.
diff --git a/testing/test_session.py b/testing/test_session.py
index 39a9769f1..f9eb95f3b 100644
--- a/testing/test_session.py
+++ b/testing/test_session.py
@@ -22,7 +22,10 @@ class SessionTests(object):
assert len(skipped) == 0
assert len(passed) == 1
assert len(failed) == 3
- end = lambda x: x.nodeid.split("::")[-1]
+
+ def end(x):
+ return x.nodeid.split("::")[-1]
+
assert end(failed[0]) == "test_one_one"
assert end(failed[1]) == "test_other"
itemstarted = reprec.getcalls("pytest_itemcollected")
diff --git a/tox.ini b/tox.ini
index 144fe623d..c6fa445af 100644
--- a/tox.ini
+++ b/tox.ini
@@ -196,6 +196,5 @@ filterwarnings =
ignore:.*inspect.getargspec.*deprecated, use inspect.signature.*:DeprecationWarning
[flake8]
-ignore = E731
max-line-length = 120
exclude = _pytest/vendored_packages/pluggy.py