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

@@ -20,7 +20,7 @@ def test_code_gives_back_name_for_not_existing_file():
assert code.fullsource is None
def test_code_with_class():
class A:
class A(object):
pass
pytest.raises(TypeError, "_pytest._code.Code(A)")
@@ -136,7 +136,7 @@ def test_frame_getargs():
('z', {'c': 'd'})]
class TestExceptionInfo:
class TestExceptionInfo(object):
def test_bad_getsource(self):
try:
@@ -147,7 +147,7 @@ class TestExceptionInfo:
assert exci.getrepr()
class TestTracebackEntry:
class TestTracebackEntry(object):
def test_getsource(self):
try:

View File

@@ -25,7 +25,7 @@ else:
import pytest
pytest_version_info = tuple(map(int, pytest.__version__.split(".")[:3]))
class TWMock:
class TWMock(object):
WRITE = object()
def __init__(self):
@@ -89,7 +89,7 @@ def h():
g()
#
class TestTraceback_f_g_h:
class TestTraceback_f_g_h(object):
def setup_method(self, method):
try:
h()
@@ -386,7 +386,7 @@ def test_match_raises_error(testdir):
"*AssertionError*Pattern*[123]*not found*",
])
class TestFormattedExcinfo:
class TestFormattedExcinfo(object):
@pytest.fixture
def importasmod(self, request):
@@ -472,7 +472,7 @@ raise ValueError()
pr = FormattedExcinfo()
class FakeCode(object):
class raw:
class raw(object):
co_filename = '?'
path = '?'

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: