New-style classes implemented for python 2.7 - #2147

This commit is contained in:
Michal Wajszczuk
2017-02-16 19:41:51 +01:00
parent da828aac05
commit fb0b90646e
61 changed files with 351 additions and 349 deletions

View File

@@ -49,7 +49,7 @@ def test_source_from_function():
assert str(source).startswith('def test_source_str_function():')
def test_source_from_method():
class TestClass:
class TestClass(object):
def test_method(self):
pass
source = _pytest._code.Source(TestClass().test_method)
@@ -119,7 +119,7 @@ def test_isparseable():
assert not Source(" \nif 1:\npass").isparseable()
assert not Source(chr(0)).isparseable()
class TestAccesses:
class TestAccesses(object):
source = Source("""\
def f(x):
pass
@@ -143,7 +143,7 @@ class TestAccesses:
l = [x for x in self.source]
assert len(l) == 4
class TestSourceParsingAndCompiling:
class TestSourceParsingAndCompiling(object):
source = Source("""\
def f(x):
assert (x ==
@@ -307,7 +307,7 @@ class TestSourceParsingAndCompiling:
pytest.raises(SyntaxError, _pytest._code.compile, "lambda a,a: 0", mode='eval')
def test_getstartingblock_singleline():
class A:
class A(object):
def __init__(self, *args):
frame = sys._getframe(1)
self.source = _pytest._code.Frame(frame).statement
@@ -318,7 +318,7 @@ def test_getstartingblock_singleline():
assert len(l) == 1
def test_getstartingblock_multiline():
class A:
class A(object):
def __init__(self, *args):
frame = sys._getframe(1)
self.source = _pytest._code.Frame(frame).statement
@@ -461,16 +461,16 @@ def test_getfslineno():
assert lineno == A_lineno
assert getfslineno(3) == ("", -1)
class B:
class B(object):
pass
B.__name__ = "B2"
assert getfslineno(B)[1] == -1
def test_code_of_object_instance_with_call():
class A:
class A(object):
pass
pytest.raises(TypeError, lambda: _pytest._code.Source(A()))
class WithCall:
class WithCall(object):
def __call__(self):
pass
@@ -559,7 +559,7 @@ x = 3
""")
assert str(source) == "raise ValueError(\n 23\n)"
class TestTry:
class TestTry(object):
pytestmark = astonly
source = """\
try:
@@ -586,7 +586,7 @@ else:
source = getstatement(5, self.source)
assert str(source) == " raise KeyError()"
class TestTryFinally:
class TestTryFinally(object):
source = """\
try:
raise ValueError
@@ -604,7 +604,7 @@ finally:
class TestIf:
class TestIf(object):
pytestmark = astonly
source = """\
if 1: