Merge pull request #1330 from nicoddemus/fix-flakes

Fix flakes
This commit is contained in:
Bruno Oliveira 2016-01-18 15:36:20 -02:00
commit 4c87a6aa09
6 changed files with 17 additions and 15 deletions

View File

@ -112,8 +112,8 @@ def pytest_runtest_setup(item):
config=item.config, op=op, left=left, right=right) config=item.config, op=op, left=left, right=right)
for new_expl in hook_result: for new_expl in hook_result:
if new_expl: if new_expl:
if (sum(len(p) for p in new_expl[1:]) > 80*8 if (sum(len(p) for p in new_expl[1:]) > 80*8 and
and item.config.option.verbose < 2): item.config.option.verbose < 2):
show_max = 10 show_max = 10
truncated_lines = len(new_expl) - show_max truncated_lines = len(new_expl) - show_max
new_expl[show_max:] = [py.builtin._totext( new_expl[show_max:] = [py.builtin._totext(

View File

@ -140,8 +140,8 @@ def assertrepr_compare(config, op, left, right):
summary = u('%s %s %s') % (ecu(left_repr), op, ecu(right_repr)) summary = u('%s %s %s') % (ecu(left_repr), op, ecu(right_repr))
issequence = lambda x: (isinstance(x, (list, tuple, Sequence)) issequence = lambda x: (isinstance(x, (list, tuple, Sequence)) and
and not isinstance(x, basestring)) not isinstance(x, basestring))
istext = lambda x: isinstance(x, basestring) istext = lambda x: isinstance(x, basestring)
isdict = lambda x: isinstance(x, dict) isdict = lambda x: isinstance(x, dict)
isset = lambda x: isinstance(x, (set, frozenset)) isset = lambda x: isinstance(x, (set, frozenset))
@ -263,8 +263,7 @@ def _compare_eq_sequence(left, right, verbose=False):
explanation += [ explanation += [
u('Right contains more items, first extra item: %s') % u('Right contains more items, first extra item: %s') %
py.io.saferepr(right[len(left)],)] py.io.saferepr(right[len(left)],)]
return explanation # + _diff_text(pprint.pformat(left), return explanation
# pprint.pformat(right))
def _compare_eq_set(left, right, verbose=False): def _compare_eq_set(left, right, verbose=False):

View File

@ -416,8 +416,8 @@ class PyCollector(PyobjMixin, pytest.Collector):
def istestfunction(self, obj, name): def istestfunction(self, obj, name):
return ( return (
(self.funcnamefilter(name) or self.isnosetest(obj)) (self.funcnamefilter(name) or self.isnosetest(obj)) and
and safe_getattr(obj, "__call__", False) and getfixturemarker(obj) is None safe_getattr(obj, "__call__", False) and getfixturemarker(obj) is None
) )
def istestclass(self, obj, name): def istestclass(self, obj, name):
@ -1765,8 +1765,10 @@ class FixtureLookupError(LookupError):
stack.extend(map(lambda x: x.func, self.fixturestack)) stack.extend(map(lambda x: x.func, self.fixturestack))
msg = self.msg msg = self.msg
if msg is not None: if msg is not None:
stack = stack[:-1] # the last fixture raise an error, let's present # the last fixture raise an error, let's present
# it at the requesting side # it at the requesting side
stack = stack[:-1]
for function in stack: for function in stack:
fspath, lineno = getfslineno(function) fspath, lineno = getfslineno(function)
try: try:

View File

@ -24,9 +24,10 @@ def pytest_pycollect_makeitem(collector, name, obj):
class UnitTestCase(pytest.Class): class UnitTestCase(pytest.Class):
nofuncargs = True # marker for fixturemanger.getfixtureinfo() # marker for fixturemanger.getfixtureinfo()
# to declare that our children do not support funcargs # to declare that our children do not support funcargs
# nofuncargs = True
def setup(self): def setup(self):
cls = self.obj cls = self.obj
if getattr(cls, '__unittest_skip__', False): if getattr(cls, '__unittest_skip__', False):

View File

@ -203,7 +203,7 @@ class TestView:
cls.View = pytest.importorskip("_pytest.assertion.oldinterpret").View cls.View = pytest.importorskip("_pytest.assertion.oldinterpret").View
def test_class_dispatch(self): 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): class Picklable(self.View):
pass pass

View File

@ -155,4 +155,4 @@ norecursedirs = .tox ja .hg cx_freeze_source
[flake8] [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