Fix flake8 E305 and E306 errors
These errors started to appear with flake8-3.1.1, while they don't appear with version 3.1.0 (weird).
This commit is contained in:
@@ -24,6 +24,7 @@ def test_code_with_class():
|
||||
pass
|
||||
pytest.raises(TypeError, "_pytest._code.Code(A)")
|
||||
|
||||
|
||||
if True:
|
||||
def x():
|
||||
pass
|
||||
@@ -68,8 +69,10 @@ def test_code_from_func():
|
||||
|
||||
def test_unicode_handling():
|
||||
value = py.builtin._totext('\xc4\x85\xc4\x87\n', 'utf-8').encode('utf8')
|
||||
|
||||
def f():
|
||||
raise Exception(value)
|
||||
|
||||
excinfo = pytest.raises(Exception, f)
|
||||
str(excinfo)
|
||||
if sys.version_info[0] < 3:
|
||||
@@ -79,8 +82,10 @@ def test_unicode_handling():
|
||||
@pytest.mark.skipif(sys.version_info[0] >= 3, reason='python 2 only issue')
|
||||
def test_unicode_handling_syntax_error():
|
||||
value = py.builtin._totext('\xc4\x85\xc4\x87\n', 'utf-8').encode('utf8')
|
||||
|
||||
def f():
|
||||
raise SyntaxError('invalid syntax', (None, 1, 3, value))
|
||||
|
||||
excinfo = pytest.raises(Exception, f)
|
||||
str(excinfo)
|
||||
if sys.version_info[0] < 3:
|
||||
|
||||
@@ -56,8 +56,10 @@ def test_excinfo_simple():
|
||||
def test_excinfo_getstatement():
|
||||
def g():
|
||||
raise ValueError
|
||||
|
||||
def f():
|
||||
g()
|
||||
|
||||
try:
|
||||
f()
|
||||
except ValueError:
|
||||
@@ -168,11 +170,13 @@ class TestTraceback_f_g_h:
|
||||
#
|
||||
raise ValueError
|
||||
#
|
||||
|
||||
def g():
|
||||
#
|
||||
__tracebackhide__ = tracebackhide
|
||||
f()
|
||||
#
|
||||
|
||||
def h():
|
||||
#
|
||||
g()
|
||||
@@ -214,15 +218,18 @@ class TestTraceback_f_g_h:
|
||||
def test_traceback_no_recursion_index(self):
|
||||
def do_stuff():
|
||||
raise RuntimeError
|
||||
|
||||
def reraise_me():
|
||||
import sys
|
||||
exc, val, tb = sys.exc_info()
|
||||
py.builtin._reraise(exc, val, tb)
|
||||
|
||||
def f(n):
|
||||
try:
|
||||
do_stuff()
|
||||
except:
|
||||
reraise_me()
|
||||
|
||||
excinfo = pytest.raises(RuntimeError, f, 8)
|
||||
traceback = excinfo.traceback
|
||||
recindex = traceback.recursionindex()
|
||||
@@ -245,17 +252,18 @@ class TestTraceback_f_g_h:
|
||||
excinfo = pytest.raises(ValueError, fail)
|
||||
assert excinfo.traceback.recursionindex() is None
|
||||
|
||||
|
||||
|
||||
def test_traceback_getcrashentry(self):
|
||||
def i():
|
||||
__tracebackhide__ = True
|
||||
raise ValueError
|
||||
|
||||
def h():
|
||||
i()
|
||||
|
||||
def g():
|
||||
__tracebackhide__ = True
|
||||
h()
|
||||
|
||||
def f():
|
||||
g()
|
||||
|
||||
@@ -271,6 +279,7 @@ class TestTraceback_f_g_h:
|
||||
def g():
|
||||
__tracebackhide__ = True
|
||||
raise ValueError
|
||||
|
||||
def f():
|
||||
__tracebackhide__ = True
|
||||
g()
|
||||
@@ -465,11 +474,13 @@ raise ValueError()
|
||||
class FakeCode(object):
|
||||
class raw:
|
||||
co_filename = '?'
|
||||
|
||||
path = '?'
|
||||
firstlineno = 5
|
||||
|
||||
def fullsource(self):
|
||||
return None
|
||||
|
||||
fullsource = property(fullsource)
|
||||
|
||||
class FakeFrame(object):
|
||||
@@ -491,17 +502,21 @@ raise ValueError()
|
||||
class FakeExcinfo(_pytest._code.ExceptionInfo):
|
||||
typename = "Foo"
|
||||
value = Exception()
|
||||
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
def exconly(self, tryshort):
|
||||
return "EXC"
|
||||
|
||||
def errisinstance(self, cls):
|
||||
return False
|
||||
|
||||
excinfo = FakeExcinfo()
|
||||
|
||||
class FakeRawTB(object):
|
||||
tb_next = None
|
||||
|
||||
tb = FakeRawTB()
|
||||
excinfo.traceback = Traceback(tb)
|
||||
|
||||
@@ -719,8 +734,10 @@ raise ValueError()
|
||||
excinfo = pytest.raises(ValueError, mod.entry)
|
||||
|
||||
p = FormattedExcinfo()
|
||||
|
||||
def raiseos():
|
||||
raise OSError(2)
|
||||
|
||||
monkeypatch.setattr(py.std.os, 'getcwd', raiseos)
|
||||
assert p._makepath(__file__) == __file__
|
||||
p.repr_traceback(excinfo)
|
||||
@@ -789,9 +806,11 @@ raise ValueError()
|
||||
|
||||
def test_reprexcinfo_unicode(self):
|
||||
from _pytest._code.code import TerminalRepr
|
||||
|
||||
class MyRepr(TerminalRepr):
|
||||
def toterminal(self, tw):
|
||||
tw.line(py.builtin._totext("я", "utf-8"))
|
||||
|
||||
x = py.builtin._totext(MyRepr())
|
||||
assert x == py.builtin._totext("я", "utf-8")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user