New-style classes implemented for python 2.7 - #2147
This commit is contained in:
@@ -20,7 +20,7 @@ class MyDocTestRunner(doctest.DocTestRunner):
|
||||
example.source.strip(), got.strip(), example.want.strip()))
|
||||
|
||||
|
||||
class TestApprox:
|
||||
class TestApprox(object):
|
||||
|
||||
def test_repr_string(self):
|
||||
# for some reason in Python 2.6 it is not displaying the tolerance representation correctly
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -20,7 +20,7 @@ def test_getfuncargnames():
|
||||
def h(arg1, arg2, arg3="hello"): pass
|
||||
assert fixtures.getfuncargnames(h) == ('arg1', 'arg2')
|
||||
|
||||
class A:
|
||||
class A(object):
|
||||
def f(self, arg1, arg2="hello"):
|
||||
pass
|
||||
|
||||
@@ -28,7 +28,7 @@ def test_getfuncargnames():
|
||||
if sys.version_info < (3,0):
|
||||
assert fixtures.getfuncargnames(A.f) == ('arg1',)
|
||||
|
||||
class TestFillFixtures:
|
||||
class TestFillFixtures(object):
|
||||
def test_fillfuncargs_exposed(self):
|
||||
# used by oejskit, kept for compatibility
|
||||
assert pytest._fillfuncargs == fixtures.fillfixtures
|
||||
@@ -79,7 +79,7 @@ class TestFillFixtures:
|
||||
def something(request):
|
||||
return request.function.__name__
|
||||
|
||||
class TestClass:
|
||||
class TestClass(object):
|
||||
def test_method(self, something):
|
||||
assert something == "test_method"
|
||||
def test_func(something):
|
||||
@@ -91,7 +91,7 @@ class TestFillFixtures:
|
||||
def test_funcarg_lookup_classlevel(self, testdir):
|
||||
p = testdir.makepyfile("""
|
||||
import pytest
|
||||
class TestClass:
|
||||
class TestClass(object):
|
||||
|
||||
@pytest.fixture
|
||||
def something(self, request):
|
||||
@@ -134,7 +134,7 @@ class TestFillFixtures:
|
||||
def spam():
|
||||
return 'spam'
|
||||
|
||||
class TestSpam:
|
||||
class TestSpam(object):
|
||||
|
||||
@pytest.fixture
|
||||
def spam(self, spam):
|
||||
@@ -463,7 +463,7 @@ class TestFillFixtures:
|
||||
assert result.ret == 0
|
||||
|
||||
|
||||
class TestRequestBasic:
|
||||
class TestRequestBasic(object):
|
||||
def test_request_attributes(self, testdir):
|
||||
item = testdir.getitem("""
|
||||
import pytest
|
||||
@@ -484,7 +484,7 @@ class TestRequestBasic:
|
||||
def test_request_attributes_method(self, testdir):
|
||||
item, = testdir.getitems("""
|
||||
import pytest
|
||||
class TestB:
|
||||
class TestB(object):
|
||||
|
||||
@pytest.fixture
|
||||
def something(self, request):
|
||||
@@ -502,7 +502,7 @@ class TestRequestBasic:
|
||||
@pytest.fixture
|
||||
def something(request):
|
||||
pass
|
||||
class TestClass:
|
||||
class TestClass(object):
|
||||
def test_method(self, something):
|
||||
pass
|
||||
""")
|
||||
@@ -704,7 +704,7 @@ class TestRequestBasic:
|
||||
def test_func():
|
||||
pass
|
||||
|
||||
class TestClass:
|
||||
class TestClass(object):
|
||||
@pytest.fixture(scope="class", autouse=True)
|
||||
def setup_class(self):
|
||||
l.append("class")
|
||||
@@ -771,7 +771,7 @@ class TestRequestBasic:
|
||||
reprec = testdir.inline_run()
|
||||
reprec.assertoutcome(passed=2)
|
||||
|
||||
class TestRequestMarking:
|
||||
class TestRequestMarking(object):
|
||||
def test_applymarker(self, testdir):
|
||||
item1,item2 = testdir.getitems("""
|
||||
import pytest
|
||||
@@ -779,7 +779,7 @@ class TestRequestMarking:
|
||||
@pytest.fixture
|
||||
def something(request):
|
||||
pass
|
||||
class TestClass:
|
||||
class TestClass(object):
|
||||
def test_func1(self, something):
|
||||
pass
|
||||
def test_func2(self, something):
|
||||
@@ -831,7 +831,7 @@ class TestRequestMarking:
|
||||
reprec = testdir.inline_run()
|
||||
reprec.assertoutcome(passed=2)
|
||||
|
||||
class TestRequestCachedSetup:
|
||||
class TestRequestCachedSetup(object):
|
||||
def test_request_cachedsetup_defaultmodule(self, testdir):
|
||||
reprec = testdir.inline_runsource("""
|
||||
mysetup = ["hello",].pop
|
||||
@@ -844,7 +844,7 @@ class TestRequestCachedSetup:
|
||||
|
||||
def test_func1(something):
|
||||
assert something == "hello"
|
||||
class TestClass:
|
||||
class TestClass(object):
|
||||
def test_func1a(self, something):
|
||||
assert something == "hello"
|
||||
""")
|
||||
@@ -862,7 +862,7 @@ class TestRequestCachedSetup:
|
||||
assert something == "hello3"
|
||||
def test_func2(something):
|
||||
assert something == "hello2"
|
||||
class TestClass:
|
||||
class TestClass(object):
|
||||
def test_func1a(self, something):
|
||||
assert something == "hello"
|
||||
def test_func2b(self, something):
|
||||
@@ -996,7 +996,7 @@ class TestRequestCachedSetup:
|
||||
"*ZeroDivisionError*",
|
||||
])
|
||||
|
||||
class TestFixtureUsages:
|
||||
class TestFixtureUsages(object):
|
||||
def test_noargfixturedec(self, testdir):
|
||||
testdir.makepyfile("""
|
||||
import pytest
|
||||
@@ -1138,7 +1138,7 @@ class TestFixtureUsages:
|
||||
def test_factory_setup_as_classes_fails(self, testdir):
|
||||
testdir.makepyfile("""
|
||||
import pytest
|
||||
class arg1:
|
||||
class arg1(object):
|
||||
def __init__(self, request):
|
||||
self.x = 1
|
||||
arg1 = pytest.fixture()(arg1)
|
||||
@@ -1172,7 +1172,7 @@ class TestFixtureUsages:
|
||||
request.cls.hello = "world"
|
||||
l.append(1)
|
||||
|
||||
class TestClass:
|
||||
class TestClass(object):
|
||||
def test_one(self):
|
||||
assert self.hello == "world"
|
||||
assert len(l) == 1
|
||||
@@ -1198,7 +1198,7 @@ class TestFixtureUsages:
|
||||
|
||||
""")
|
||||
testdir.makepyfile("""
|
||||
class TestClass:
|
||||
class TestClass(object):
|
||||
def test_one(self):
|
||||
assert self.hello == "world"
|
||||
def test_two(self):
|
||||
@@ -1217,7 +1217,7 @@ class TestFixtureUsages:
|
||||
testdir.makepyfile("""
|
||||
import pytest
|
||||
|
||||
class TestClass:
|
||||
class TestClass(object):
|
||||
@pytest.fixture
|
||||
def setup1(self, request):
|
||||
assert self == request.instance
|
||||
@@ -1256,7 +1256,7 @@ class TestFixtureUsages:
|
||||
assert l == [1,2, 10,20]
|
||||
|
||||
|
||||
class TestFixtureManagerParseFactories:
|
||||
class TestFixtureManagerParseFactories(object):
|
||||
|
||||
@pytest.fixture
|
||||
def testdir(self, request):
|
||||
@@ -1280,7 +1280,7 @@ class TestFixtureManagerParseFactories:
|
||||
|
||||
def test_parsefactories_evil_objects_issue214(self, testdir):
|
||||
testdir.makepyfile("""
|
||||
class A:
|
||||
class A(object):
|
||||
def __call__(self):
|
||||
pass
|
||||
def __getattr__(self, name):
|
||||
@@ -1311,7 +1311,7 @@ class TestFixtureManagerParseFactories:
|
||||
@pytest.fixture
|
||||
def hello(request):
|
||||
return "module"
|
||||
class TestClass:
|
||||
class TestClass(object):
|
||||
@pytest.fixture
|
||||
def hello(self, request):
|
||||
return "class"
|
||||
@@ -1360,7 +1360,7 @@ class TestFixtureManagerParseFactories:
|
||||
reprec.assertoutcome(passed=2)
|
||||
|
||||
|
||||
class TestAutouseDiscovery:
|
||||
class TestAutouseDiscovery(object):
|
||||
|
||||
@pytest.fixture
|
||||
def testdir(self, testdir):
|
||||
@@ -1402,14 +1402,14 @@ class TestAutouseDiscovery:
|
||||
def test_two_classes_separated_autouse(self, testdir):
|
||||
testdir.makepyfile("""
|
||||
import pytest
|
||||
class TestA:
|
||||
class TestA(object):
|
||||
l = []
|
||||
@pytest.fixture(autouse=True)
|
||||
def setup1(self):
|
||||
self.l.append(1)
|
||||
def test_setup1(self):
|
||||
assert self.l == [1]
|
||||
class TestB:
|
||||
class TestB(object):
|
||||
l = []
|
||||
@pytest.fixture(autouse=True)
|
||||
def setup2(self):
|
||||
@@ -1423,7 +1423,7 @@ class TestAutouseDiscovery:
|
||||
def test_setup_at_classlevel(self, testdir):
|
||||
testdir.makepyfile("""
|
||||
import pytest
|
||||
class TestClass:
|
||||
class TestClass(object):
|
||||
@pytest.fixture(autouse=True)
|
||||
def permethod(self, request):
|
||||
request.instance.funcname = request.function.__name__
|
||||
@@ -1505,13 +1505,13 @@ class TestAutouseDiscovery:
|
||||
def test_x():
|
||||
assert l == ["module"]
|
||||
|
||||
class TestA:
|
||||
class TestA(object):
|
||||
@pytest.fixture(autouse=True)
|
||||
def append2(self):
|
||||
l.append("A")
|
||||
def test_hello(self):
|
||||
assert l == ["module", "module", "A"], l
|
||||
class TestA2:
|
||||
class TestA2(object):
|
||||
def test_world(self):
|
||||
assert l == ["module", "module", "A", "module"], l
|
||||
""")
|
||||
@@ -1519,7 +1519,7 @@ class TestAutouseDiscovery:
|
||||
reprec.assertoutcome(passed=3)
|
||||
|
||||
|
||||
class TestAutouseManagement:
|
||||
class TestAutouseManagement(object):
|
||||
def test_autouse_conftest_mid_directory(self, testdir):
|
||||
pkgdir = testdir.mkpydir("xyz123")
|
||||
pkgdir.join("conftest.py").write(_pytest._code.Source("""
|
||||
@@ -1654,10 +1654,10 @@ class TestAutouseManagement:
|
||||
testdir.makepyfile("""
|
||||
import pytest
|
||||
|
||||
class TestClass:
|
||||
class TestClass(object):
|
||||
def test_1(self):
|
||||
pass
|
||||
class TestClass2:
|
||||
class TestClass2(object):
|
||||
def test_2(self):
|
||||
pass
|
||||
""")
|
||||
@@ -1682,7 +1682,7 @@ class TestAutouseManagement:
|
||||
def mappend():
|
||||
l.append(1)
|
||||
|
||||
class TestHallo:
|
||||
class TestHallo(object):
|
||||
def test_method(self):
|
||||
assert l == [1,3,2]
|
||||
""")
|
||||
@@ -1696,7 +1696,7 @@ class TestAutouseManagement:
|
||||
def pytest_generate_tests(metafunc):
|
||||
if metafunc.cls is not None:
|
||||
metafunc.parametrize("item", [1,2], scope="class")
|
||||
class TestClass:
|
||||
class TestClass(object):
|
||||
@pytest.fixture(scope="class", autouse=True)
|
||||
def addteardown(self, item, request):
|
||||
l.append("setup-%d" % item)
|
||||
@@ -1756,7 +1756,7 @@ class TestAutouseManagement:
|
||||
reprec.assertoutcome(passed=2)
|
||||
|
||||
|
||||
class TestFixtureMarker:
|
||||
class TestFixtureMarker(object):
|
||||
def test_parametrize(self, testdir):
|
||||
testdir.makepyfile("""
|
||||
import pytest
|
||||
@@ -1822,7 +1822,7 @@ class TestFixtureMarker:
|
||||
def test_2(arg):
|
||||
assert arg == 1
|
||||
assert len(l) == 1
|
||||
class TestClass:
|
||||
class TestClass(object):
|
||||
def test3(self, arg):
|
||||
assert arg == 1
|
||||
assert len(l) == 1
|
||||
@@ -1916,7 +1916,7 @@ class TestFixtureMarker:
|
||||
def test_2(arg):
|
||||
assert arg == 1
|
||||
assert len(l) == 1
|
||||
class TestClass:
|
||||
class TestClass(object):
|
||||
def test3(self, arg):
|
||||
assert arg == 1
|
||||
assert len(l) == 1
|
||||
@@ -2135,12 +2135,12 @@ class TestFixtureMarker:
|
||||
testdir.makepyfile("""
|
||||
import pytest
|
||||
|
||||
class TestClass2:
|
||||
class TestClass2(object):
|
||||
def test_1(self):
|
||||
pass
|
||||
def test_2(self):
|
||||
pass
|
||||
class TestClass:
|
||||
class TestClass(object):
|
||||
def test_3(self):
|
||||
pass
|
||||
""")
|
||||
@@ -2213,7 +2213,7 @@ class TestFixtureMarker:
|
||||
|
||||
l = []
|
||||
|
||||
class TestClass:
|
||||
class TestClass(object):
|
||||
@classmethod
|
||||
@pytest.fixture(scope="class", autouse=True)
|
||||
def setup1(self, request, param1):
|
||||
@@ -2273,7 +2273,7 @@ class TestFixtureMarker:
|
||||
testpath = testdir.makepyfile("""
|
||||
import pytest
|
||||
|
||||
class Box:
|
||||
class Box(object):
|
||||
value = 0
|
||||
|
||||
@pytest.fixture(scope='class')
|
||||
@@ -2284,11 +2284,11 @@ class TestFixtureMarker:
|
||||
def test_a(a):
|
||||
assert a == 1
|
||||
|
||||
class Test1:
|
||||
class Test1(object):
|
||||
def test_b(self, a):
|
||||
assert a == 2
|
||||
|
||||
class Test2:
|
||||
class Test2(object):
|
||||
def test_c(self, a):
|
||||
assert a == 3""")
|
||||
reprec = testdir.inline_run(testpath)
|
||||
@@ -2402,11 +2402,11 @@ class TestFixtureMarker:
|
||||
request.addfinalizer(lambda: l.append("fin %s" % request.param))
|
||||
return request.param
|
||||
|
||||
class TestGreetings:
|
||||
class TestGreetings(object):
|
||||
def test_hello(self, human):
|
||||
l.append("test_hello")
|
||||
|
||||
class TestMetrics:
|
||||
class TestMetrics(object):
|
||||
def test_name(self, human):
|
||||
l.append("test_name")
|
||||
|
||||
@@ -2499,7 +2499,7 @@ class TestFixtureMarker:
|
||||
'*test_foo*beta*'])
|
||||
|
||||
|
||||
class TestRequestScopeAccess:
|
||||
class TestRequestScopeAccess(object):
|
||||
pytestmark = pytest.mark.parametrize(("scope", "ok", "error"),[
|
||||
["session", "", "fspath class function module"],
|
||||
["module", "module fspath", "cls function"],
|
||||
@@ -2543,7 +2543,7 @@ class TestRequestScopeAccess:
|
||||
reprec = testdir.inline_run()
|
||||
reprec.assertoutcome(passed=1)
|
||||
|
||||
class TestErrors:
|
||||
class TestErrors(object):
|
||||
def test_subfactory_missing_funcarg(self, testdir):
|
||||
testdir.makepyfile("""
|
||||
import pytest
|
||||
@@ -2607,7 +2607,7 @@ class TestErrors:
|
||||
"*1 error*",
|
||||
])
|
||||
|
||||
class TestShowFixtures:
|
||||
class TestShowFixtures(object):
|
||||
def test_funcarg_compat(self, testdir):
|
||||
config = testdir.parseconfigure("--funcargs")
|
||||
assert config.option.showfixtures
|
||||
@@ -2770,7 +2770,7 @@ class TestShowFixtures:
|
||||
|
||||
|
||||
@pytest.mark.parametrize('flavor', ['fixture', 'yield_fixture'])
|
||||
class TestContextManagerFixtureFuncs:
|
||||
class TestContextManagerFixtureFuncs(object):
|
||||
|
||||
def test_simple(self, testdir, flavor):
|
||||
testdir.makepyfile("""
|
||||
@@ -2877,7 +2877,7 @@ class TestContextManagerFixtureFuncs:
|
||||
result = testdir.runpytest("-s")
|
||||
result.stdout.fnmatch_lines("*mew*")
|
||||
|
||||
class TestParameterizedSubRequest:
|
||||
class TestParameterizedSubRequest(object):
|
||||
def test_call_from_fixture(self, testdir):
|
||||
testfile = testdir.makepyfile("""
|
||||
import pytest
|
||||
|
||||
@@ -3,7 +3,7 @@ from _pytest import python
|
||||
from _pytest import runner
|
||||
|
||||
|
||||
class TestOEJSKITSpecials:
|
||||
class TestOEJSKITSpecials(object):
|
||||
def test_funcarg_non_pycollectobj(self, testdir): # rough jstests usage
|
||||
testdir.makeconftest("""
|
||||
import pytest
|
||||
@@ -19,7 +19,7 @@ class TestOEJSKITSpecials:
|
||||
@pytest.fixture
|
||||
def arg1(request):
|
||||
return 42
|
||||
class MyClass:
|
||||
class MyClass(object):
|
||||
pass
|
||||
""")
|
||||
# this hook finds funcarg factories
|
||||
@@ -48,7 +48,7 @@ class TestOEJSKITSpecials:
|
||||
@pytest.fixture
|
||||
def arg1(request):
|
||||
return 42
|
||||
class MyClass:
|
||||
class MyClass(object):
|
||||
pass
|
||||
""")
|
||||
# this hook finds funcarg factories
|
||||
@@ -76,7 +76,7 @@ def test_wrapped_getfslineno():
|
||||
fs2, lineno2 = python.getfslineno(wrap)
|
||||
assert lineno > lineno2, "getfslineno does not unwrap correctly"
|
||||
|
||||
class TestMockDecoration:
|
||||
class TestMockDecoration(object):
|
||||
def test_wrapped_getfuncargnames(self):
|
||||
from _pytest.compat import getfuncargnames
|
||||
|
||||
@@ -207,7 +207,7 @@ class TestMockDecoration:
|
||||
@patch('os.getcwd')
|
||||
@patch('os.path')
|
||||
@mark.slow
|
||||
class TestSimple:
|
||||
class TestSimple(object):
|
||||
def test_simple_thing(self, mock_path, mock_getcwd):
|
||||
pass
|
||||
""")
|
||||
@@ -215,7 +215,7 @@ class TestMockDecoration:
|
||||
reprec.assertoutcome(passed=1)
|
||||
|
||||
|
||||
class TestReRunTests:
|
||||
class TestReRunTests(object):
|
||||
def test_rerun(self, testdir):
|
||||
testdir.makeconftest("""
|
||||
from _pytest.runner import runtestprotocol
|
||||
@@ -251,7 +251,7 @@ def test_pytestconfig_is_session_scoped():
|
||||
assert pytestconfig._pytestfixturefunction.scope == "session"
|
||||
|
||||
|
||||
class TestNoselikeTestAttribute:
|
||||
class TestNoselikeTestAttribute(object):
|
||||
def test_module_with_global_test(self, testdir):
|
||||
testdir.makepyfile("""
|
||||
__test__ = False
|
||||
@@ -270,7 +270,7 @@ class TestNoselikeTestAttribute:
|
||||
pass
|
||||
test_func.__test__ = False
|
||||
|
||||
class TestSome:
|
||||
class TestSome(object):
|
||||
__test__ = False
|
||||
def test_method(self):
|
||||
pass
|
||||
@@ -328,7 +328,7 @@ class TestNoselikeTestAttribute:
|
||||
|
||||
|
||||
@pytest.mark.issue351
|
||||
class TestParameterize:
|
||||
class TestParameterize(object):
|
||||
|
||||
def test_idfn_marker(self, testdir):
|
||||
testdir.makepyfile("""
|
||||
|
||||
@@ -13,12 +13,12 @@ from hypothesis import strategies
|
||||
PY3 = sys.version_info >= (3, 0)
|
||||
|
||||
|
||||
class TestMetafunc:
|
||||
class TestMetafunc(object):
|
||||
def Metafunc(self, func):
|
||||
# the unit tests of this class check if things work correctly
|
||||
# on the funcarg level, so we don't need a full blown
|
||||
# initiliazation
|
||||
class FixtureInfo:
|
||||
class FixtureInfo(object):
|
||||
name2fixturedefs = None
|
||||
|
||||
def __init__(self, names):
|
||||
@@ -68,7 +68,7 @@ class TestMetafunc:
|
||||
def func(arg1): pass
|
||||
metafunc = self.Metafunc(func)
|
||||
|
||||
class obj: pass
|
||||
class obj(object): pass
|
||||
|
||||
metafunc.addcall(param=obj)
|
||||
metafunc.addcall(param=obj)
|
||||
@@ -83,7 +83,7 @@ class TestMetafunc:
|
||||
|
||||
metafunc = self.Metafunc(func)
|
||||
|
||||
class obj: pass
|
||||
class obj(object): pass
|
||||
|
||||
metafunc.addcall(funcargs={"x": 2})
|
||||
metafunc.addcall(funcargs={"x": 3})
|
||||
@@ -150,7 +150,7 @@ class TestMetafunc:
|
||||
def func(x, y): pass
|
||||
metafunc = self.Metafunc(func)
|
||||
|
||||
class A:
|
||||
class A(object):
|
||||
pass
|
||||
|
||||
metafunc.parametrize("x", [A(), A()])
|
||||
@@ -601,7 +601,7 @@ class TestMetafunc:
|
||||
pytestmark = pytest.mark.parametrize("x", [1,2])
|
||||
def test_func(x):
|
||||
assert 0, x
|
||||
class TestClass:
|
||||
class TestClass(object):
|
||||
pytestmark = pytest.mark.parametrize("y", [3,4])
|
||||
def test_meth(self, x, y):
|
||||
assert 0, x
|
||||
@@ -672,7 +672,7 @@ class TestMetafunc:
|
||||
assert fixtures._format_args(function4) == "(arg1, *args, **kwargs)"
|
||||
|
||||
|
||||
class TestMetafuncFunctional:
|
||||
class TestMetafuncFunctional(object):
|
||||
def test_attributes(self, testdir):
|
||||
p = testdir.makepyfile("""
|
||||
# assumes that generate/provide runs in the same process
|
||||
@@ -691,7 +691,7 @@ class TestMetafuncFunctional:
|
||||
assert metafunc.function == test_function
|
||||
assert metafunc.cls is None
|
||||
|
||||
class TestClass:
|
||||
class TestClass(object):
|
||||
def test_method(self, metafunc, pytestconfig):
|
||||
assert metafunc.config == pytestconfig
|
||||
assert metafunc.module.__name__ == __name__
|
||||
@@ -716,7 +716,7 @@ class TestMetafuncFunctional:
|
||||
def pytest_generate_tests(metafunc):
|
||||
metafunc.addcall(funcargs=dict(arg1=1, arg2=1))
|
||||
|
||||
class TestClass:
|
||||
class TestClass(object):
|
||||
def test_myfunc(self, arg1, arg2):
|
||||
assert arg1 == arg2
|
||||
""")
|
||||
@@ -756,7 +756,7 @@ class TestMetafuncFunctional:
|
||||
def pytest_generate_tests(metafunc):
|
||||
assert 'xyz' not in metafunc.fixturenames
|
||||
|
||||
class TestHello:
|
||||
class TestHello(object):
|
||||
def test_hello(xyz):
|
||||
pass
|
||||
""")
|
||||
@@ -782,7 +782,7 @@ class TestMetafuncFunctional:
|
||||
def arg2(request):
|
||||
return request.param[1]
|
||||
|
||||
class TestClass:
|
||||
class TestClass(object):
|
||||
def test_myfunc(self, arg1, arg2):
|
||||
assert arg1 == arg2
|
||||
""")
|
||||
@@ -795,7 +795,7 @@ class TestMetafuncFunctional:
|
||||
|
||||
def test_generate_tests_in_class(self, testdir):
|
||||
p = testdir.makepyfile("""
|
||||
class TestClass:
|
||||
class TestClass(object):
|
||||
def pytest_generate_tests(self, metafunc):
|
||||
metafunc.addcall(funcargs={'hello': 'world'}, id="hello")
|
||||
|
||||
@@ -814,7 +814,7 @@ class TestMetafuncFunctional:
|
||||
metafunc.addcall({'arg1': 10})
|
||||
metafunc.addcall({'arg1': 20})
|
||||
|
||||
class TestClass:
|
||||
class TestClass(object):
|
||||
def test_func(self, arg1):
|
||||
assert not hasattr(self, 'x')
|
||||
self.x = 1
|
||||
@@ -831,7 +831,7 @@ class TestMetafuncFunctional:
|
||||
def pytest_generate_tests(metafunc):
|
||||
metafunc.addcall({'arg1': 1})
|
||||
|
||||
class TestClass:
|
||||
class TestClass(object):
|
||||
def test_method(self, arg1):
|
||||
assert arg1 == self.val
|
||||
def setup_method(self, func):
|
||||
@@ -1117,7 +1117,7 @@ class TestMetafuncFunctional:
|
||||
assert expectederror in failures[0].longrepr.reprcrash.message
|
||||
|
||||
|
||||
class TestMetafuncFunctionalAuto:
|
||||
class TestMetafuncFunctionalAuto(object):
|
||||
"""
|
||||
Tests related to automatically find out the correct scope for parametrized tests (#1832).
|
||||
"""
|
||||
@@ -1236,7 +1236,7 @@ class TestMetafuncFunctionalAuto:
|
||||
assert output.count('preparing foo-3') == 1
|
||||
|
||||
|
||||
class TestMarkersWithParametrization:
|
||||
class TestMarkersWithParametrization(object):
|
||||
pytestmark = pytest.mark.issue308
|
||||
def test_simple_mark(self, testdir):
|
||||
s = """
|
||||
|
||||
@@ -2,7 +2,7 @@ import pytest
|
||||
import sys
|
||||
|
||||
|
||||
class TestRaises:
|
||||
class TestRaises(object):
|
||||
def test_raises(self):
|
||||
source = "int('qwe')"
|
||||
excinfo = pytest.raises(ValueError, source)
|
||||
@@ -20,7 +20,7 @@ class TestRaises:
|
||||
pytest.raises(ValueError, int, 'hello')
|
||||
|
||||
def test_raises_callable_no_exception(self):
|
||||
class A:
|
||||
class A(object):
|
||||
def __call__(self):
|
||||
pass
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user