From 7b13c4bec0cdea33fd92a9c0b437b77d8537fc00 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Thu, 14 Jan 2016 21:01:07 -0200 Subject: [PATCH] Fix flakes --- _pytest/assertion/__init__.py | 4 ++-- _pytest/assertion/util.py | 7 +++---- _pytest/python.py | 10 ++++++---- _pytest/unittest.py | 7 ++++--- testing/test_assertinterpret.py | 2 +- tox.ini | 2 +- 6 files changed, 17 insertions(+), 15 deletions(-) diff --git a/_pytest/assertion/__init__.py b/_pytest/assertion/__init__.py index 54742347c..865b33c8c 100644 --- a/_pytest/assertion/__init__.py +++ b/_pytest/assertion/__init__.py @@ -112,8 +112,8 @@ def pytest_runtest_setup(item): config=item.config, op=op, left=left, right=right) for new_expl in hook_result: if new_expl: - if (sum(len(p) for p in new_expl[1:]) > 80*8 - and item.config.option.verbose < 2): + if (sum(len(p) for p in new_expl[1:]) > 80*8 and + item.config.option.verbose < 2): show_max = 10 truncated_lines = len(new_expl) - show_max new_expl[show_max:] = [py.builtin._totext( diff --git a/_pytest/assertion/util.py b/_pytest/assertion/util.py index ca54f1692..401d04f10 100644 --- a/_pytest/assertion/util.py +++ b/_pytest/assertion/util.py @@ -140,8 +140,8 @@ 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)) + 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)) @@ -263,8 +263,7 @@ def _compare_eq_sequence(left, right, verbose=False): explanation += [ u('Right contains more items, first extra item: %s') % py.io.saferepr(right[len(left)],)] - return explanation # + _diff_text(pprint.pformat(left), - # pprint.pformat(right)) + return explanation def _compare_eq_set(left, right, verbose=False): diff --git a/_pytest/python.py b/_pytest/python.py index 926f503be..6f3a717af 100644 --- a/_pytest/python.py +++ b/_pytest/python.py @@ -416,8 +416,8 @@ class PyCollector(PyobjMixin, pytest.Collector): def istestfunction(self, obj, name): return ( - (self.funcnamefilter(name) or self.isnosetest(obj)) - and safe_getattr(obj, "__call__", False) and getfixturemarker(obj) is None + (self.funcnamefilter(name) or self.isnosetest(obj)) and + safe_getattr(obj, "__call__", False) and getfixturemarker(obj) is None ) def istestclass(self, obj, name): @@ -1765,8 +1765,10 @@ class FixtureLookupError(LookupError): stack.extend(map(lambda x: x.func, self.fixturestack)) msg = self.msg if msg is not None: - stack = stack[:-1] # the last fixture raise an error, let's present - # it at the requesting side + # the last fixture raise an error, let's present + # it at the requesting side + stack = stack[:-1] + for function in stack: fspath, lineno = getfslineno(function) try: diff --git a/_pytest/unittest.py b/_pytest/unittest.py index bb7579331..24fa9e921 100644 --- a/_pytest/unittest.py +++ b/_pytest/unittest.py @@ -24,9 +24,10 @@ def pytest_pycollect_makeitem(collector, name, obj): class UnitTestCase(pytest.Class): - nofuncargs = True # marker for fixturemanger.getfixtureinfo() - # to declare that our children do not support funcargs - # + # marker for fixturemanger.getfixtureinfo() + # to declare that our children do not support funcargs + nofuncargs = True + def setup(self): cls = self.obj if getattr(cls, '__unittest_skip__', False): diff --git a/testing/test_assertinterpret.py b/testing/test_assertinterpret.py index 209bdfd49..afbfbd9cb 100644 --- a/testing/test_assertinterpret.py +++ b/testing/test_assertinterpret.py @@ -203,7 +203,7 @@ class TestView: cls.View = pytest.importorskip("_pytest.assertion.oldinterpret").View def test_class_dispatch(self): - ### Use a custom class hierarchy with existing instances + # Use a custom class hierarchy with existing instances class Picklable(self.View): pass diff --git a/tox.ini b/tox.ini index 32336f20e..90468dbcf 100644 --- a/tox.ini +++ b/tox.ini @@ -155,4 +155,4 @@ norecursedirs = .tox ja .hg cx_freeze_source [flake8] -ignore =E401,E225,E261,E128,E124,E301,E302,E121,E303,W391,E501,E231,E126,E701,E265,E241,E251,E226,E101,W191,E131,E203,E122,E123,E271,E712,E222,E127,E125,E221,W292,E111,E113,E293,E262,W293,E129,E702,E201,E272,E202 +ignore =E401,E225,E261,E128,E124,E301,E302,E121,E303,W391,E501,E231,E126,E701,E265,E241,E251,E226,E101,W191,E131,E203,E122,E123,E271,E712,E222,E127,E125,E221,W292,E111,E113,E293,E262,W293,E129,E702,E201,E272,E202,E704,E731,E402