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

@@ -12,7 +12,7 @@ from _pytest.main import (
)
class TestModule:
class TestModule(object):
def test_failing_import(self, testdir):
modcol = testdir.getmodulecol("import alksdjalskdjalkjals")
pytest.raises(Collector.CollectError, modcol.collect)
@@ -105,10 +105,10 @@ class TestModule:
assert name not in stdout
class TestClass:
class TestClass(object):
def test_class_with_init_warning(self, testdir):
testdir.makepyfile("""
class TestClass1:
class TestClass1(object):
def __init__(self):
pass
""")
@@ -129,7 +129,7 @@ class TestClass:
def test_setup_teardown_class_as_classmethod(self, testdir):
testdir.makepyfile(test_mod1="""
class TestClassMethod:
class TestClassMethod(object):
@classmethod
def setup_class(cls):
pass
@@ -167,7 +167,7 @@ class TestClass:
)
class TestGenerator:
class TestGenerator(object):
def test_generative_functions(self, testdir):
modcol = testdir.getmodulecol("""
def func1(arg, arg2):
@@ -192,7 +192,7 @@ class TestGenerator:
modcol = testdir.getmodulecol("""
def func1(arg, arg2):
assert arg == arg2
class TestGenMethods:
class TestGenMethods(object):
def test_gen(self):
yield func1, 17, 3*5
yield func1, 42, 6*7
@@ -246,7 +246,7 @@ class TestGenerator:
modcol = testdir.getmodulecol("""
def func1(arg, arg2):
assert arg == arg2
class TestGenMethods:
class TestGenMethods(object):
def test_gen(self):
yield "m1", func1, 17, 3*5
yield "m2", func1, 42, 6*7
@@ -326,7 +326,7 @@ class TestGenerator:
# has been used during collection.
o = testdir.makepyfile("""
setuplist = []
class TestClass:
class TestClass(object):
def setup_method(self, func):
#print "setup_method", self, func
setuplist.append(self)
@@ -360,7 +360,7 @@ class TestGenerator:
assert not skipped and not failed
class TestFunction:
class TestFunction(object):
def test_getmodulecollector(self, testdir):
item = testdir.getitem("def test_func(): pass")
modcol = item.getparent(pytest.Module)
@@ -369,7 +369,7 @@ class TestFunction:
def test_function_as_object_instance_ignored(self, testdir):
testdir.makepyfile("""
class A:
class A(object):
def __call__(self, tmpdir):
0/0
@@ -420,7 +420,7 @@ class TestFunction:
def test_issue213_parametrize_value_no_equal(self, testdir):
testdir.makepyfile("""
import pytest
class A:
class A(object):
def __eq__(self, other):
raise ValueError("not possible")
@pytest.mark.parametrize('arg', [A()])
@@ -551,11 +551,11 @@ class TestFunction:
item = testdir.getitem("def test_func(): raise ValueError")
config = item.config
class MyPlugin1:
class MyPlugin1(object):
def pytest_pyfunc_call(self, pyfuncitem):
raise ValueError
class MyPlugin2:
class MyPlugin2(object):
def pytest_pyfunc_call(self, pyfuncitem):
return True
@@ -683,7 +683,7 @@ class TestFunction:
assert [x.originalname for x in items] == ['test_func', 'test_func']
class TestSorting:
class TestSorting(object):
def test_check_equality(self, testdir):
modcol = testdir.getmodulecol("""
def test_pass(): pass
@@ -733,7 +733,7 @@ class TestSorting:
assert [item.name for item in colitems] == ['test_b', 'test_a']
class TestConftestCustomization:
class TestConftestCustomization(object):
def test_pytest_pycollect_module(self, testdir):
testdir.makeconftest("""
import pytest
@@ -847,7 +847,7 @@ def test_modulecol_roundtrip(testdir):
assert modcol.name == newcol.name
class TestTracebackCutting:
class TestTracebackCutting(object):
def test_skip_simple(self):
excinfo = pytest.raises(pytest.skip.Exception, 'pytest.skip("xxx")')
assert excinfo.traceback[-1].frame.code.name == "skip"
@@ -973,7 +973,7 @@ class TestTracebackCutting:
assert filter_traceback(tb[-1])
class TestReportInfo:
class TestReportInfo(object):
def test_itemreport_reportinfo(self, testdir, linecomp):
testdir.makeconftest("""
import pytest
@@ -998,7 +998,7 @@ class TestReportInfo:
def test_class_reportinfo(self, testdir):
modcol = testdir.getmodulecol("""
# lineno 0
class TestClass:
class TestClass(object):
def test_hello(self): pass
""")
classcol = testdir.collect_by_name(modcol, "TestClass")
@@ -1033,7 +1033,7 @@ class TestReportInfo:
def check(x):
pass
yield check, 3
class TestClass:
class TestClass(object):
def test_method(self):
pass
"""
@@ -1042,7 +1042,7 @@ class TestReportInfo:
# https://github.com/pytest-dev/pytest/issues/1204
modcol = testdir.getmodulecol("""
# lineno 0
class TestClass:
class TestClass(object):
def __getattr__(self, name):
return "this is not an int"
@@ -1064,7 +1064,7 @@ def test_customized_python_discovery(testdir):
p = testdir.makepyfile("""
def check_simple():
pass
class CheckMyApp:
class CheckMyApp(object):
def check_meth(self):
pass
""")
@@ -1139,7 +1139,7 @@ def test_customize_through_attributes(testdir):
return MyClass(name, parent=collector)
""")
testdir.makepyfile("""
class MyTestClass:
class MyTestClass(object):
def test_hello(self):
pass
""")
@@ -1153,11 +1153,11 @@ def test_customize_through_attributes(testdir):
def test_unorderable_types(testdir):
testdir.makepyfile("""
class TestJoinEmpty:
class TestJoinEmpty(object):
pass
def make_test():
class Test:
class Test(object):
pass
Test.__name__ = "TestFoo"
return Test