diff --git a/AUTHORS b/AUTHORS index 43c7d3156be..e9e7f7c828e 100644 --- a/AUTHORS +++ b/AUTHORS @@ -108,6 +108,7 @@ Michael Aquilina Michael Birtwell Michael Droettboom Michael Seifert +Michal Wajszczuk Mike Lundy Ned Batchelder Neven Mundar diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 4abc183d0cd..23b87b18c35 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -21,7 +21,7 @@ Changes ------- * Old-style classes have been changed to new-style classes in order to improve - compatability with Python 2. Thanks to `@mandeep`_ for the PR (`#2147`_). + compatibility with Python 2. Thanks to `@MichalTHEDUDE`_ and `@mandeep`_ for the PR (`#2147`_). * It is now possible to skip test classes from being collected by setting a ``__test__`` attribute to ``False`` in the class body (`#2007`_). Thanks @@ -61,6 +61,7 @@ Changes .. _@wheerd: https://github.com/wheerd .. _@fogo: https://github.com/fogo .. _@mandeep: https://github.com/mandeep +.. _@MichalTHEDUDE: https://github.com/MichalTHEDUDE .. _@unsignedint: https://github.com/unsignedint .. _@Kriechi: https://github.com/Kriechi diff --git a/_pytest/vendored_packages/pluggy.py b/_pytest/vendored_packages/pluggy.py index a300053a111..11658c3b149 100644 --- a/_pytest/vendored_packages/pluggy.py +++ b/_pytest/vendored_packages/pluggy.py @@ -167,7 +167,7 @@ def normalize_hookimpl_opts(opts): opts.setdefault("optionalhook", False) -class _TagTracer: +class _TagTracer(object): def __init__(self): self._tag2proc = {} self.writer = None @@ -214,7 +214,7 @@ def setprocessor(self, tags, processor): self._tag2proc[tags] = processor -class _TagTracerSub: +class _TagTracerSub(object): def __init__(self, root, tags): self.root = root self.tags = tags @@ -254,7 +254,7 @@ def _wrapped_call(wrap_controller, func): return call_outcome.get_result() -class _CallOutcome: +class _CallOutcome(object): """ Outcome of a function call, either an exception or a proper result. Calling the ``get_result`` method will return the result or reraise the exception raised when the function was called. """ @@ -286,7 +286,7 @@ def _reraise(cls, val, tb): """) -class _TracedHookExecution: +class _TracedHookExecution(object): def __init__(self, pluginmanager, before, after): self.pluginmanager = pluginmanager self.before = before @@ -580,7 +580,7 @@ def subset_hook_caller(self, name, remove_plugins): return orig -class _MultiCall: +class _MultiCall(object): """ execute a call into multiple python functions/methods. """ # XXX note that the __multicall__ argument is supported only @@ -673,7 +673,7 @@ def varnames(func, startindex=None): return x -class _HookRelay: +class _HookRelay(object): """ hook holder object for performing 1:N hook calls where N is the number of registered plugins. diff --git a/doc/en/assert.rst b/doc/en/assert.rst index d93da178d6a..5ec07a78e3e 100644 --- a/doc/en/assert.rst +++ b/doc/en/assert.rst @@ -223,7 +223,7 @@ provides an alternative explanation for ``Foo`` objects:: now, given this test module:: # content of test_foocompare.py - class Foo: + class Foo(object): def __init__(self, val): self.val = val diff --git a/doc/en/example/assertion/failure_demo.py b/doc/en/example/assertion/failure_demo.py index a4ff758b18c..d31fba2adaa 100644 --- a/doc/en/example/assertion/failure_demo.py +++ b/doc/en/example/assertion/failure_demo.py @@ -128,7 +128,7 @@ class Bar(object): def globf(x): return x+1 -class TestRaises: +class TestRaises(object): def test_raises(self): s = 'qwe' raises(TypeError, "int(s)") @@ -167,7 +167,7 @@ def test_dynamic_compile_shows_nicely(): -class TestMoreErrors: +class TestMoreErrors(object): def test_complex_error(self): def f(): return 44 @@ -213,23 +213,23 @@ def test_try_finally(self): x = 0 -class TestCustomAssertMsg: +class TestCustomAssertMsg(object): def test_single_line(self): - class A: + class A(object): a = 1 b = 2 assert A.a == b, "A.a appears not to be b" def test_multiline(self): - class A: + class A(object): a = 1 b = 2 assert A.a == b, "A.a appears not to be b\n" \ "or does not appear to be b\none of those" def test_custom_repr(self): - class JSON: + class JSON(object): a = 1 def __repr__(self): return "This is JSON\n{\n 'foo': 'bar'\n}" diff --git a/doc/en/example/assertion/test_setup_flow_example.py b/doc/en/example/assertion/test_setup_flow_example.py index 512330cb4c7..100effa499f 100644 --- a/doc/en/example/assertion/test_setup_flow_example.py +++ b/doc/en/example/assertion/test_setup_flow_example.py @@ -1,7 +1,7 @@ def setup_module(module): module.TestStateFullThing.classcount = 0 -class TestStateFullThing: +class TestStateFullThing(object): def setup_class(cls): cls.classcount += 1 diff --git a/doc/en/example/attic.rst b/doc/en/example/attic.rst index 1bc32b2837d..6004ebb8f17 100644 --- a/doc/en/example/attic.rst +++ b/doc/en/example/attic.rst @@ -15,7 +15,7 @@ example: specifying and selecting acceptance tests def pytest_funcarg__accept(request): return AcceptFixture(request) - class AcceptFixture: + class AcceptFixture(object): def __init__(self, request): if not request.config.option.acceptance: pytest.skip("specify -A to run acceptance tests") @@ -61,7 +61,7 @@ extend the `accept example`_ by putting this in our test module: arg.tmpdir.mkdir("special") return arg - class TestSpecialAcceptance: + class TestSpecialAcceptance(object): def test_sometest(self, accept): assert accept.tmpdir.join("special").check() diff --git a/doc/en/example/costlysetup/conftest.py b/doc/en/example/costlysetup/conftest.py index c8b9a257e32..ea3c1cffb72 100644 --- a/doc/en/example/costlysetup/conftest.py +++ b/doc/en/example/costlysetup/conftest.py @@ -7,7 +7,7 @@ def setup(request): yield setup setup.finalize() -class CostlySetup: +class CostlySetup(object): def __init__(self): import time print ("performing costly setup") diff --git a/doc/en/example/markers.rst b/doc/en/example/markers.rst index 7dd5c835941..ab5c03f1786 100644 --- a/doc/en/example/markers.rst +++ b/doc/en/example/markers.rst @@ -21,7 +21,7 @@ You can "mark" a test function with custom metadata like this:: pass def test_another(): pass - class TestClass: + class TestClass(object): def test_method(self): pass @@ -242,7 +242,7 @@ its test methods:: # content of test_mark_classlevel.py import pytest @pytest.mark.webtest - class TestClass: + class TestClass(object): def test_startup(self): pass def test_startup_and_more(self): @@ -256,14 +256,14 @@ To remain backward-compatible with Python 2.4 you can also set a import pytest - class TestClass: + class TestClass(object): pytestmark = pytest.mark.webtest or if you need to use multiple markers you can use a list:: import pytest - class TestClass: + class TestClass(object): pytestmark = [pytest.mark.webtest, pytest.mark.slowtest] You can also set a module level marker:: @@ -407,7 +407,7 @@ code you can read over all such settings. Example:: pytestmark = pytest.mark.glob("module", x=1) @pytest.mark.glob("class", x=2) - class TestClass: + class TestClass(object): @pytest.mark.glob("function", x=3) def test_something(self): pass diff --git a/doc/en/example/multipython.py b/doc/en/example/multipython.py index 1f5e976ef1e..586f441848f 100644 --- a/doc/en/example/multipython.py +++ b/doc/en/example/multipython.py @@ -16,7 +16,7 @@ def python1(request, tmpdir): def python2(request, python1): return Python(request.param, python1.picklefile) -class Python: +class Python(object): def __init__(self, version, picklefile): self.pythonpath = py.path.local.sysfind(version) if not self.pythonpath: diff --git a/doc/en/example/parametrize.rst b/doc/en/example/parametrize.rst index 609158590ab..f0572e9a1ee 100644 --- a/doc/en/example/parametrize.rst +++ b/doc/en/example/parametrize.rst @@ -168,7 +168,7 @@ only have to work a bit to construct the correct arguments for pytest's scenario1 = ('basic', {'attribute': 'value'}) scenario2 = ('advanced', {'attribute': 'value2'}) - class TestSampleWithScenarios: + class TestSampleWithScenarios(object): scenarios = [scenario1, scenario2] def test_demo1(self, attribute): @@ -241,9 +241,9 @@ creates a database object for the actual test invocations:: if 'db' in metafunc.fixturenames: metafunc.parametrize("db", ['d1', 'd2'], indirect=True) - class DB1: + class DB1(object): "one database object" - class DB2: + class DB2(object): "alternative database object" @pytest.fixture @@ -350,7 +350,7 @@ parametrizer`_ but in a lot less code:: metafunc.parametrize(argnames, [[funcargs[name] for name in argnames] for funcargs in funcarglist]) - class TestClass: + class TestClass(object): # a map specifying multiple argument sets for a test method params = { 'test_equals': [dict(a=1, b=2), dict(a=3, b=3), ], diff --git a/doc/en/example/pythoncollection.py b/doc/en/example/pythoncollection.py index 0b9e35df484..9c4bd31cea0 100644 --- a/doc/en/example/pythoncollection.py +++ b/doc/en/example/pythoncollection.py @@ -4,7 +4,7 @@ def test_function(): pass -class TestClass: +class TestClass(object): def test_method(self): pass def test_anothermethod(self): diff --git a/doc/en/example/pythoncollection.rst b/doc/en/example/pythoncollection.rst index 0d53b059302..e3ab5f0cd7e 100644 --- a/doc/en/example/pythoncollection.rst +++ b/doc/en/example/pythoncollection.rst @@ -107,7 +107,7 @@ This would make ``pytest`` look for tests in files that match the ``check_* that match ``*_check``. For example, if we have:: # content of check_myapp.py - class CheckMyApp: + class CheckMyApp(object): def simple_check(self): pass def complex_check(self): diff --git a/doc/en/example/reportingdemo.rst b/doc/en/example/reportingdemo.rst index 14120832142..44d2f15a455 100644 --- a/doc/en/example/reportingdemo.rst +++ b/doc/en/example/reportingdemo.rst @@ -550,7 +550,7 @@ get on the terminal - we are working on that):: self = def test_single_line(self): - class A: + class A(object): a = 1 b = 2 > assert A.a == b, "A.a appears not to be b" @@ -564,7 +564,7 @@ get on the terminal - we are working on that):: self = def test_multiline(self): - class A: + class A(object): a = 1 b = 2 > assert A.a == b, "A.a appears not to be b\n" \ @@ -581,7 +581,7 @@ get on the terminal - we are working on that):: self = def test_custom_repr(self): - class JSON: + class JSON(object): a = 1 def __repr__(self): return "This is JSON\n{\n 'foo': 'bar'\n}" diff --git a/doc/en/example/simple.rst b/doc/en/example/simple.rst index d4b3fba43b3..c4935e2c518 100644 --- a/doc/en/example/simple.rst +++ b/doc/en/example/simple.rst @@ -425,7 +425,7 @@ tests in a class. Here is a test module example: import pytest @pytest.mark.incremental - class TestUserHandling: + class TestUserHandling(object): def test_login(self): pass def test_modification(self): @@ -483,7 +483,7 @@ Here is an example for making a ``db`` fixture available in a directory: # content of a/conftest.py import pytest - class DB: + class DB(object): pass @pytest.fixture(scope="session") diff --git a/doc/en/example/special.rst b/doc/en/example/special.rst index fdffef089a0..1fc32f6c817 100644 --- a/doc/en/example/special.rst +++ b/doc/en/example/special.rst @@ -28,7 +28,7 @@ will be called ahead of running any tests:: # content of test_module.py - class TestHello: + class TestHello(object): @classmethod def callme(cls): print ("callme called!") @@ -39,7 +39,7 @@ will be called ahead of running any tests:: def test_method2(self): print ("test_method1 called") - class TestOther: + class TestOther(object): @classmethod def callme(cls): print ("callme other called") diff --git a/doc/en/fixture.rst b/doc/en/fixture.rst index 0a900061164..6f88aad73e8 100644 --- a/doc/en/fixture.rst +++ b/doc/en/fixture.rst @@ -557,7 +557,7 @@ and instantiate an object ``app`` where we stick the already defined import pytest - class App: + class App(object): def __init__(self, smtp): self.smtp = smtp @@ -728,7 +728,7 @@ and declare its use in a test module via a ``usefixtures`` marker:: import pytest @pytest.mark.usefixtures("cleandir") - class TestDirectoryInit: + class TestDirectoryInit(object): def test_cwd_starts_empty(self): assert os.listdir(os.getcwd()) == [] with open("myfile", "w") as f: @@ -791,7 +791,7 @@ self-contained implementation of this idea:: import pytest - class DB: + class DB(object): def __init__(self): self.intransaction = [] def begin(self, name): @@ -803,7 +803,7 @@ self-contained implementation of this idea:: def db(): return DB() - class TestClass: + class TestClass(object): @pytest.fixture(autouse=True) def transact(self, request, db): db.begin(request.function.__name__) @@ -861,7 +861,7 @@ into a conftest.py file **without** using ``autouse``:: and then e.g. have a TestClass using it by declaring the need:: @pytest.mark.usefixtures("transact") - class TestClass: + class TestClass(object): def test_method1(self): ... diff --git a/doc/en/funcarg_compare.rst b/doc/en/funcarg_compare.rst index 3d121b944fd..b857a014d31 100644 --- a/doc/en/funcarg_compare.rst +++ b/doc/en/funcarg_compare.rst @@ -24,7 +24,7 @@ resources. Here is a basic example how we could implement a per-session Database object:: # content of conftest.py - class Database: + class Database(object): def __init__(self): print ("database instance created") def destroy(self): diff --git a/doc/en/genapi.py b/doc/en/genapi.py index 89ddc873169..0ede44fa2de 100644 --- a/doc/en/genapi.py +++ b/doc/en/genapi.py @@ -1,7 +1,7 @@ import textwrap import inspect -class Writer: +class Writer(object): def __init__(self, clsname): self.clsname = clsname diff --git a/doc/en/getting-started.rst b/doc/en/getting-started.rst index 557e8245d65..488ac301f4b 100644 --- a/doc/en/getting-started.rst +++ b/doc/en/getting-started.rst @@ -111,7 +111,7 @@ to group tests logically, in classes and modules. Let's write a class containing two tests:: # content of test_class.py - class TestClass: + class TestClass(object): def test_one(self): x = "this" assert 'h' in x diff --git a/doc/en/skipping.rst b/doc/en/skipping.rst index 0a2e18208c5..cdcb56c2c96 100644 --- a/doc/en/skipping.rst +++ b/doc/en/skipping.rst @@ -98,7 +98,7 @@ You can use the ``skipif`` decorator (and any other marker) on classes:: @pytest.mark.skipif(sys.platform == 'win32', reason="does not run on windows") - class TestPosixCalls: + class TestPosixCalls(object): def test_function(self): "will not be setup or run under 'win32' platform" diff --git a/doc/en/test/attic.rst b/doc/en/test/attic.rst index 11140db2c0b..06944661cb5 100644 --- a/doc/en/test/attic.rst +++ b/doc/en/test/attic.rst @@ -110,7 +110,7 @@ If you want to disable a complete test class you can set the class-level attribute ``disabled``. For example, in order to avoid running some tests on Win32:: - class TestPosixOnly: + class TestPosixOnly(object): disabled = sys.platform == 'win32' def test_xxx(self): diff --git a/doc/en/unittest.rst b/doc/en/unittest.rst index 1bee0e14630..78aac427a63 100644 --- a/doc/en/unittest.rst +++ b/doc/en/unittest.rst @@ -71,7 +71,7 @@ it from a unittest-style test:: @pytest.fixture(scope="class") def db_class(request): - class DummyDB: + class DummyDB(object): pass # set a class attribute on the invoking test context request.cls.db = DummyDB() diff --git a/doc/en/usage.rst b/doc/en/usage.rst index 15b3d71b077..d5d35993e8d 100644 --- a/doc/en/usage.rst +++ b/doc/en/usage.rst @@ -226,7 +226,7 @@ to all testcases you can use ``LogXML.add_global_properties`` def start_and_prepare_env(): pass - class TestMe: + class TestMe(object): def test_foo(self): assert True @@ -314,7 +314,7 @@ You can specify additional plugins to ``pytest.main``:: # content of myinvoke.py import pytest - class MyPlugin: + class MyPlugin(object): def pytest_sessionfinish(self): print("*** test run reporting finishing") diff --git a/testing/acceptance_test.py b/testing/acceptance_test.py index 88e3fa44934..0d3fc101623 100644 --- a/testing/acceptance_test.py +++ b/testing/acceptance_test.py @@ -8,7 +8,7 @@ from _pytest.main import EXIT_NOTESTSCOLLECTED, EXIT_USAGEERROR -class TestGeneralUsage: +class TestGeneralUsage(object): def test_config_error(self, testdir): testdir.makeconftest(""" def pytest_configure(config): @@ -410,7 +410,7 @@ def test_stuff(r): ]) -class TestInvocationVariants: +class TestInvocationVariants(object): def test_earlyinit(self, testdir): p = testdir.makepyfile(""" import pytest @@ -502,7 +502,7 @@ def test_invoke_with_path(self, tmpdir, capsys): out, err = capsys.readouterr() def test_invoke_plugin_api(self, testdir, capsys): - class MyPlugin: + class MyPlugin(object): def pytest_addoption(self, parser): parser.addoption("--myopt") @@ -670,7 +670,7 @@ def test_has_plugin(self, request): assert request.config.pluginmanager.hasplugin('python') -class TestDurations: +class TestDurations(object): source = """ import time frag = 0.002 @@ -741,7 +741,7 @@ def test_with_not(self, testdir): assert result.ret == 0 -class TestDurationWithFixture: +class TestDurationWithFixture(object): source = """ import time frag = 0.001 diff --git a/testing/code/test_code.py b/testing/code/test_code.py index ad9db6d2e4f..a1f31b4a983 100644 --- a/testing/code/test_code.py +++ b/testing/code/test_code.py @@ -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 f4(x, *y, **z): ('z', {'c': 'd'})] -class TestExceptionInfo: +class TestExceptionInfo(object): def test_bad_getsource(self): try: @@ -147,7 +147,7 @@ def test_bad_getsource(self): assert exci.getrepr() -class TestTracebackEntry: +class TestTracebackEntry(object): def test_getsource(self): try: diff --git a/testing/code/test_excinfo.py b/testing/code/test_excinfo.py index 23b0a985e2e..e2354ff5d7f 100644 --- a/testing/code/test_excinfo.py +++ b/testing/code/test_excinfo.py @@ -25,7 +25,7 @@ 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_division_zero(): "*AssertionError*Pattern*[123]*not found*", ]) -class TestFormattedExcinfo: +class TestFormattedExcinfo(object): @pytest.fixture def importasmod(self, request): @@ -472,7 +472,7 @@ def test_repr_source_failing_fullsource(self): pr = FormattedExcinfo() class FakeCode(object): - class raw: + class raw(object): co_filename = '?' path = '?' diff --git a/testing/code/test_source.py b/testing/code/test_source.py index 13bfccd547d..c161f75f8d3 100644 --- a/testing/code/test_source.py +++ b/testing/code/test_source.py @@ -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 @@ def test_iter(self): 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 @@ def test_offsetless_synerr(self): 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 __init__(self, *args): 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 @@ class A(object): 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 @@ def XXXtest_multiline(): """) assert str(source) == "raise ValueError(\n 23\n)" -class TestTry: +class TestTry(object): pytestmark = astonly source = """\ try: @@ -586,7 +586,7 @@ def test_else(self): source = getstatement(5, self.source) assert str(source) == " raise KeyError()" -class TestTryFinally: +class TestTryFinally(object): source = """\ try: raise ValueError @@ -604,7 +604,7 @@ def test_finally(self): -class TestIf: +class TestIf(object): pytestmark = astonly source = """\ if 1: diff --git a/testing/deprecated_test.py b/testing/deprecated_test.py index e610458e072..6473989e62d 100644 --- a/testing/deprecated_test.py +++ b/testing/deprecated_test.py @@ -48,7 +48,7 @@ def test_str_args_deprecated(tmpdir, testdir): from _pytest.main import EXIT_NOTESTSCOLLECTED warnings = [] - class Collect: + class Collect(object): def pytest_logwarning(self, message): warnings.append(message) diff --git a/testing/python/approx.py b/testing/python/approx.py index fc1cbf9ab7b..d7063e2150f 100644 --- a/testing/python/approx.py +++ b/testing/python/approx.py @@ -20,7 +20,7 @@ def report_failure(self, out, test, example, got): 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 diff --git a/testing/python/collect.py b/testing/python/collect.py index 1e69f2da939..5511b3d7594 100644 --- a/testing/python/collect.py +++ b/testing/python/collect.py @@ -12,7 +12,7 @@ ) -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 @@ def test_show_traceback_import_error(self, testdir, verbose): 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 test(object): 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 @@ def test_issue1579_namedtuple(self, testdir): ) -class TestGenerator: +class TestGenerator(object): def test_generative_functions(self, testdir): modcol = testdir.getmodulecol(""" def func1(arg, arg2): @@ -192,7 +192,7 @@ def test_generative_methods(self, testdir): 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 @@ def test_generative_methods_with_explicit_names(self, testdir): 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 @@ def test_setupstate_is_preserved_134(self, testdir): # 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 @@ def test_setuplist(): 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 @@ def test_getmodulecollector(self, testdir): 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 @@ def test_function(arg): 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 @@ def test_pyfunc_call(self, testdir): 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 @@ def test_func(arg): 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 @@ def test_a(y): 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 @@ def foo(): 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 @@ def test_func_reportinfo(self, testdir): 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 @@ def test_genfunc(): def check(x): pass yield check, 3 - class TestClass: + class TestClass(object): def test_method(self): pass """ @@ -1042,7 +1042,7 @@ def test_reportinfo_with_nasty_getattr(self, testdir): # 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 pytest_pycollect_makeitem(collector, name, obj): return MyClass(name, parent=collector) """) testdir.makepyfile(""" - class MyTestClass: + class MyTestClass(object): def test_hello(self): pass """) @@ -1153,11 +1153,11 @@ def test_hello(self): 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 diff --git a/testing/python/fixture.py b/testing/python/fixture.py index be99ed833ef..269d2c68a56 100644 --- a/testing/python/fixture.py +++ b/testing/python/fixture.py @@ -20,7 +20,7 @@ def h(arg1, arg2="hello"): pass 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 f(self, arg1, arg2="hello"): 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 @@ def test_funcarg_lookup_modulelevel(self, testdir): 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 @@ def test_func(something): 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 @@ def test_extend_fixture_module_class(self, testdir): def spam(): return 'spam' - class TestSpam: + class TestSpam(object): @pytest.fixture def spam(self, spam): @@ -463,7 +463,7 @@ def test_leak(leak): assert result.ret == 0 -class TestRequestBasic: +class TestRequestBasic(object): def test_request_attributes(self, testdir): item = testdir.getitem(""" import pytest @@ -484,7 +484,7 @@ def test_func(something): pass 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 @@ def test_request_contains_funcarg_arg2fixturedefs(self, testdir): @pytest.fixture def something(request): pass - class TestClass: + class TestClass(object): def test_method(self, something): pass """) @@ -704,7 +704,7 @@ def setup_function(): 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 @@ def test_1(arg): 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 @@ def test_applymarker(self, testdir): @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 @@ def test_fun2(keywords): 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 @@ def something(request): def test_func1(something): assert something == "hello" - class TestClass: + class TestClass(object): def test_func1a(self, something): assert something == "hello" """) @@ -862,7 +862,7 @@ def test_func1(something): 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 @@ def test_func(app): "*ZeroDivisionError*", ]) -class TestFixtureUsages: +class TestFixtureUsages(object): def test_noargfixturedec(self, testdir): testdir.makepyfile(""" import pytest @@ -1138,7 +1138,7 @@ def test_missing(call_fail): 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 @@ def myfix(request): 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 @@ def myfix(request): """) testdir.makepyfile(""" - class TestClass: + class TestClass(object): def test_one(self): assert self.hello == "world" def test_two(self): @@ -1217,7 +1217,7 @@ def test_request_instance_issue203(self, testdir): testdir.makepyfile(""" import pytest - class TestClass: + class TestClass(object): @pytest.fixture def setup1(self, request): assert self == request.instance @@ -1256,7 +1256,7 @@ def test_2(arg2): assert l == [1,2, 10,20] -class TestFixtureManagerParseFactories: +class TestFixtureManagerParseFactories(object): @pytest.fixture def testdir(self, request): @@ -1280,7 +1280,7 @@ def item(request): 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 @@ def test_parsefactories_conftest_and_module_and_class(self, testdir): @pytest.fixture def hello(request): return "module" - class TestClass: + class TestClass(object): @pytest.fixture def hello(self, request): return "class" @@ -1360,7 +1360,7 @@ def test_x(one): reprec.assertoutcome(passed=2) -class TestAutouseDiscovery: +class TestAutouseDiscovery(object): @pytest.fixture def testdir(self, testdir): @@ -1402,14 +1402,14 @@ def test_check_setup(item, fm): 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 @@ def test_setup2(self): 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 @@ def append1(): 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 @@ def test_world(self): 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 @@ def fin(): 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 @@ def classappend3(): def mappend(): l.append(1) - class TestHallo: + class TestHallo(object): def test_method(self): assert l == [1,3,2] """) @@ -1696,7 +1696,7 @@ def test_parametrization_setup_teardown_ordering(self, testdir): 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 @@ def test_check(): reprec.assertoutcome(passed=2) -class TestFixtureMarker: +class TestFixtureMarker(object): def test_parametrize(self, testdir): testdir.makepyfile(""" import pytest @@ -1822,7 +1822,7 @@ def test_1(arg): 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 @@ def test_1(arg): 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 @@ def fin(): 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 @@ def param1(request): l = [] - class TestClass: + class TestClass(object): @classmethod @pytest.fixture(scope="class", autouse=True) def setup1(self, request, param1): @@ -2273,7 +2273,7 @@ def test_class_scope_with_normal_tests(self, testdir): testpath = testdir.makepyfile(""" import pytest - class Box: + class Box(object): value = 0 @pytest.fixture(scope='class') @@ -2284,11 +2284,11 @@ def a(request): 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 @@ def human(request): 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 @@ def test_foo(fix): '*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 @@ def test_func(arg): 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 @@ def test_something(): "*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 @@ def test_bar(arg1): @pytest.mark.parametrize('flavor', ['fixture', 'yield_fixture']) -class TestContextManagerFixtureFuncs: +class TestContextManagerFixtureFuncs(object): def test_simple(self, testdir, flavor): testdir.makepyfile(""" @@ -2877,7 +2877,7 @@ def test_1(meow): 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 diff --git a/testing/python/integration.py b/testing/python/integration.py index 6697342ea20..4f888276b71 100644 --- a/testing/python/integration.py +++ b/testing/python/integration.py @@ -3,7 +3,7 @@ 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 @@ def reportinfo(self): @pytest.fixture def arg1(request): return 42 - class MyClass: + class MyClass(object): pass """) # this hook finds funcarg factories @@ -48,7 +48,7 @@ def hello(): @pytest.fixture def arg1(request): return 42 - class MyClass: + class MyClass(object): pass """) # this hook finds funcarg factories @@ -76,7 +76,7 @@ def wrapped_func(x, y, z): 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 @@ def test_mock_double_patch_issue473(self, testdir): @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 @@ def test_simple_thing(self, mock_path, mock_getcwd): 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 @@ def test_func(): pass test_func.__test__ = False - class TestSome: + class TestSome(object): __test__ = False def test_method(self): pass @@ -328,7 +328,7 @@ def test_blah(self): @pytest.mark.issue351 -class TestParameterize: +class TestParameterize(object): def test_idfn_marker(self, testdir): testdir.makepyfile(""" diff --git a/testing/python/metafunc.py b/testing/python/metafunc.py index 372794a65b0..949b265a3c5 100644 --- a/testing/python/metafunc.py +++ b/testing/python/metafunc.py @@ -13,12 +13,12 @@ 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 @@ def test_addcall_param(self): 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 @@ def func(x): pass 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 @@ def test_parametrize_with_userobjects(self): def func(x, y): pass metafunc = self.Metafunc(func) - class A: + class A(object): pass metafunc.parametrize("x", [A(), A()]) @@ -601,7 +601,7 @@ def test_parametrize_multiple_times(self, testdir): 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 @@ def function4(arg1, *args, **kwargs): pass 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 @@ def test_function(metafunc, pytestconfig): 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 @@ def pytest_generate_tests(metafunc): 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 @@ def test_noself_in_method(self, testdir): 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 @@ def arg1(request): 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 @@ def test_myfunc(self, arg1, arg2): 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 @@ def pytest_generate_tests(metafunc): 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 @@ def test_issue28_setup_method_in_generate_tests(self, testdir): 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 @@ def test_foo(x): 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 @@ def pytest_generate_tests(metafunc): assert output.count('preparing foo-3') == 1 -class TestMarkersWithParametrization: +class TestMarkersWithParametrization(object): pytestmark = pytest.mark.issue308 def test_simple_mark(self, testdir): s = """ diff --git a/testing/python/raises.py b/testing/python/raises.py index 8170ec793e5..21a6f808c0d 100644 --- a/testing/python/raises.py +++ b/testing/python/raises.py @@ -2,7 +2,7 @@ import sys -class TestRaises: +class TestRaises(object): def test_raises(self): source = "int('qwe')" excinfo = pytest.raises(ValueError, source) @@ -20,7 +20,7 @@ def test_raises_function(self): pytest.raises(ValueError, int, 'hello') def test_raises_callable_no_exception(self): - class A: + class A(object): def __call__(self): pass try: diff --git a/testing/test_argcomplete.py b/testing/test_argcomplete.py index ace7d8ceb43..ed6db4c7851 100644 --- a/testing/test_argcomplete.py +++ b/testing/test_argcomplete.py @@ -69,7 +69,7 @@ def __call__(self, prefix, **kwargs): completion += [f + '/' for f in anticomp] return completion -class TestArgComplete: +class TestArgComplete(object): @pytest.mark.skipif("sys.platform in ('win32', 'darwin')") def test_compare_with_compgen(self): from _pytest._argcomplete import FastFilesCompleter diff --git a/testing/test_assertion.py b/testing/test_assertion.py index 8cfd0ad8544..fc2819f69ea 100644 --- a/testing/test_assertion.py +++ b/testing/test_assertion.py @@ -25,7 +25,7 @@ def getoption(self, name): return Config() -class TestImportHookInstallation: +class TestImportHookInstallation(object): @pytest.mark.parametrize('initial_conftest', [True, False]) @pytest.mark.parametrize('mode', ['plain', 'rewrite']) @@ -159,7 +159,7 @@ def check(values, value): plugin_state = "{plugin_state}" - class DummyDistInfo: + class DummyDistInfo(object): project_name = 'spam' version = '1.0' @@ -174,7 +174,7 @@ def _get_metadata(self, name): 'hampkg/__init__.py'] return [] - class DummyEntryPoint: + class DummyEntryPoint(object): name = 'spam' module_name = 'spam.py' attrs = () @@ -257,7 +257,7 @@ def test_register_assert_rewrite_checks_types(self): 'pytest_tests_internal_non_existing2') -class TestBinReprIntegration: +class TestBinReprIntegration(object): def test_pytest_assertrepr_compare_called(self, testdir): testdir.makeconftest(""" @@ -288,7 +288,7 @@ def callequal(left, right, verbose=False): return plugin.pytest_assertrepr_compare(config, '==', left, right) -class TestAssert_reprcompare: +class TestAssert_reprcompare(object): def test_different_types(self): assert callequal([0, 1], 'foo') is None @@ -442,7 +442,7 @@ def test_list_tuples(self): assert len(expl) > 1 def test_list_bad_repr(self): - class A: + class A(object): def __repr__(self): raise ValueError(42) expl = callequal([], [A()]) @@ -501,7 +501,7 @@ def test_mojibake(self): assert msg -class TestFormatExplanation: +class TestFormatExplanation(object): def test_special_chars_full(self, testdir): # Issue 453, for the bug this would raise IndexError @@ -593,7 +593,7 @@ def test_fmt_multi_newline_before_where(self): assert util.format_explanation(expl) == res -class TestTruncateExplanation: +class TestTruncateExplanation(object): """ Confirm assertion output is truncated as expected """ diff --git a/testing/test_assertrewrite.py b/testing/test_assertrewrite.py index fdf674f25cc..0ec528e8243 100644 --- a/testing/test_assertrewrite.py +++ b/testing/test_assertrewrite.py @@ -57,7 +57,7 @@ def getmsg(f, extra_ns=None, must_pass=False): pytest.fail("function didn't raise at all") -class TestAssertionRewrite: +class TestAssertionRewrite(object): def test_place_initial_imports(self): s = """'Doc string'\nother = stuff""" @@ -333,7 +333,7 @@ def f(): @pytest.mark.skipif("sys.version_info < (3,5)") def test_at_operator_issue1290(self, testdir): testdir.makepyfile(""" - class Matrix: + class Matrix(object): def __init__(self, num): self.num = num def __matmul__(self, other): @@ -515,7 +515,7 @@ def __repr__(self): assert r"where 1 = \n{ \n~ \n}.a" in util._format_lines([getmsg(f)])[0] -class TestRewriteOnImport: +class TestRewriteOnImport(object): def test_pycache_is_a_file(self, testdir): testdir.tmpdir.join("__pycache__").write("Hello") @@ -884,7 +884,7 @@ def test_get_data_support(self, testdir): """ path = testdir.mkpydir("foo") path.join("test_foo.py").write(_pytest._code.Source(""" - class Test: + class Test(object): def test_foo(self): import pkgutil data = pkgutil.get_data('foo.test_foo', 'data.txt') @@ -912,7 +912,7 @@ def test_long_repr(): assert 'unbalanced braces' not in result.stdout.str() -class TestIssue925(): +class TestIssue925(object): def test_simple_case(self, testdir): testdir.makepyfile(""" def test_ternary_display(): diff --git a/testing/test_cache.py b/testing/test_cache.py index 98053f86947..c1b98489e22 100755 --- a/testing/test_cache.py +++ b/testing/test_cache.py @@ -7,7 +7,7 @@ pytest_plugins = "pytester", -class TestNewAPI: +class TestNewAPI(object): def test_config_cache_makedir(self, testdir): testdir.makeini("[pytest]") config = testdir.parseconfigure() @@ -129,7 +129,7 @@ def pytest_configure(config): ]) -class TestLastFailed: +class TestLastFailed(object): def test_lastfailed_usecase(self, testdir, monkeypatch): monkeypatch.setenv("PYTHONDONTWRITEBYTECODE", 1) diff --git a/testing/test_capture.py b/testing/test_capture.py index cbb5fc81bb7..365329f59d0 100644 --- a/testing/test_capture.py +++ b/testing/test_capture.py @@ -55,7 +55,7 @@ def StdCapture(out=True, err=True, in_=True): return capture.MultiCapture(out, err, in_, Capture=capture.SysCapture) -class TestCaptureManager: +class TestCaptureManager(object): def test_getmethod_default_no_fd(self, monkeypatch): from _pytest.capture import pytest_addoption from _pytest.config import Parser @@ -154,7 +154,7 @@ def test_collect_capturing(testdir): ]) -class TestPerTestCapturing: +class TestPerTestCapturing(object): def test_capture_and_fixtures(self, testdir): p = testdir.makepyfile(""" def setup_module(mod): @@ -275,7 +275,7 @@ def test_capturing_error(): ]) -class TestLoggingInteraction: +class TestLoggingInteraction(object): def test_logging_stream_ownership(self, testdir): p = testdir.makepyfile(""" def test_logging(): @@ -395,7 +395,7 @@ def test_hello(): assert 'operation on closed file' not in result.stderr.str() -class TestCaptureFixture: +class TestCaptureFixture(object): @pytest.mark.parametrize("opt", [[], ["-s"]]) def test_std_functional(self, testdir, opt): reprec = testdir.inline_runsource(""" @@ -622,7 +622,7 @@ def bad_snap(self): ]) -class TestTextIO: +class TestTextIO(object): def test_text(self): f = capture.TextIO() f.write("hello") @@ -737,7 +737,7 @@ def lsof_check(): assert len2 < len1 + 3, out2 -class TestFDCapture: +class TestFDCapture(object): pytestmark = needsosdup def test_simple(self, tmpfile): @@ -832,7 +832,7 @@ def saved_fd(fd): os.close(new_fd) -class TestStdCapture: +class TestStdCapture(object): captureclass = staticmethod(StdCapture) @contextlib.contextmanager @@ -990,7 +990,7 @@ def test_many(self, capfd): cap.stop_capturing() -class TestStdCaptureFDinvalidFD: +class TestStdCaptureFDinvalidFD(object): pytestmark = needsosdup def test_stdcapture_fd_invalid_fd(self, testdir): diff --git a/testing/test_collection.py b/testing/test_collection.py index 4e44874e13e..8575aa63a37 100644 --- a/testing/test_collection.py +++ b/testing/test_collection.py @@ -2,7 +2,7 @@ from _pytest.main import Session, EXIT_NOTESTSCOLLECTED -class TestCollector: +class TestCollector(object): def test_collect_versus_item(self): from pytest import Collector, Item assert not issubclass(Collector, Item) @@ -50,7 +50,7 @@ def test_fail(): assert 0 def test_getparent(self, testdir): modcol = testdir.getmodulecol(""" - class TestClass: + class TestClass(object): def test_foo(): pass """) @@ -88,7 +88,7 @@ def pytest_collect_file(path, parent): def test_can_skip_class_with_test_attr(self, testdir): """Assure test class is skipped when using `__test__=False` (See #2007).""" testdir.makepyfile(""" - class TestFoo(): + class TestFoo(object): __test__ = False def __init__(self): pass @@ -101,7 +101,7 @@ def test_foo(): '*no tests ran in*', ]) -class TestCollectFS: +class TestCollectFS(object): def test_ignored_certain_directories(self, testdir): tmpdir = testdir.tmpdir tmpdir.ensure("build", 'test_notfound.py') @@ -163,11 +163,11 @@ def test_testpaths_ini(self, testdir, monkeypatch): assert [x.name for x in items] == ['test_%s' % dirname] -class TestCollectPluginHookRelay: +class TestCollectPluginHookRelay(object): def test_pytest_collect_file(self, testdir): wascalled = [] - class Plugin: + class Plugin(object): def pytest_collect_file(self, path, parent): if not path.basename.startswith("."): # Ignore hidden files, e.g. .testmondata. @@ -181,7 +181,7 @@ def pytest_collect_file(self, path, parent): def test_pytest_collect_directory(self, testdir): wascalled = [] - class Plugin: + class Plugin(object): def pytest_collect_directory(self, path, parent): wascalled.append(path.basename) @@ -192,7 +192,7 @@ def pytest_collect_directory(self, path, parent): assert "world" in wascalled -class TestPrunetraceback: +class TestPrunetraceback(object): def test_custom_repr_failure(self, testdir): p = testdir.makepyfile(""" @@ -238,7 +238,7 @@ def pytest_make_collect_report(__multicall__): ]) -class TestCustomConftests: +class TestCustomConftests(object): def test_ignore_collect_path(self, testdir): testdir.makeconftest(""" def pytest_ignore_collect(path, config): @@ -333,7 +333,7 @@ def pytest_collect_file(path, parent): "*test_x*" ]) -class TestSession: +class TestSession(object): def test_parsearg(self, testdir): p = testdir.makepyfile("def test_func(): pass") subdir = testdir.mkdir("sub") @@ -391,7 +391,7 @@ def test_collect_protocol_single_function(self, testdir): def test_collect_protocol_method(self, testdir): p = testdir.makepyfile(""" - class TestClass: + class TestClass(object): def test_method(self): pass """) @@ -490,7 +490,7 @@ def test_serialization_byid(self, testdir): def test_find_byid_without_instance_parents(self, testdir): p = testdir.makepyfile(""" - class TestClass: + class TestClass(object): def test_method(self): pass """) @@ -500,7 +500,7 @@ def test_method(self): item, = items assert item.nodeid.endswith("TestClass::()::test_method") -class Test_getinitialnodes: +class Test_getinitialnodes(object): def test_global_file(self, testdir, tmpdir): x = tmpdir.ensure("x.py") with tmpdir.as_cwd(): @@ -527,7 +527,7 @@ def test_pkgfile(self, testdir): for col in col.listchain(): assert col.config is config -class Test_genitems: +class Test_genitems(object): def test_check_collect_hashes(self, testdir): p = testdir.makepyfile(""" def test_1(): @@ -550,7 +550,7 @@ def test_example_items1(self, testdir): def testone(): pass - class TestX: + class TestX(object): def testmethod_one(self): pass @@ -583,11 +583,11 @@ def test_class_and_functions_discovery_using_glob(self, testdir): python_functions = *_test test """) p = testdir.makepyfile(''' - class MyTestSuite: + class MyTestSuite(object): def x_test(self): pass - class TestCase: + class TestCase(object): def test_y(self): pass ''') @@ -602,7 +602,7 @@ def test_matchnodes_two_collections_same_file(testdir): def pytest_configure(config): config.pluginmanager.register(Plugin2()) - class Plugin2: + class Plugin2(object): def pytest_collect_file(self, path, parent): if path.ext == ".abc": return MyFile2(path, parent) @@ -634,7 +634,7 @@ def runtest(self): ]) -class TestNodekeywords: +class TestNodekeywords(object): def test_no_under(self, testdir): modcol = testdir.getmodulecol(""" def test_pass(): pass diff --git a/testing/test_config.py b/testing/test_config.py index e6aa423e83a..7876063bd9c 100644 --- a/testing/test_config.py +++ b/testing/test_config.py @@ -4,7 +4,7 @@ from _pytest.config import getcfg, get_common_ancestor, determine_setup from _pytest.main import EXIT_NOTESTSCOLLECTED -class TestParseIni: +class TestParseIni(object): @pytest.mark.parametrize('section, filename', [('pytest', 'pytest.ini'), ('tool:pytest', 'setup.cfg')]) @@ -84,7 +84,7 @@ def test_confcutdir(self, testdir): result = testdir.inline_run("--confcutdir=.") assert result.ret == 0 -class TestConfigCmdlineParsing: +class TestConfigCmdlineParsing(object): def test_parsing_again_fails(self, testdir): config = testdir.parseconfig() pytest.raises(AssertionError, lambda: config.parse([])) @@ -115,7 +115,7 @@ def test_absolute_win32_path(self, testdir): ret = pytest.main("-c " + temp_cfg_file) assert ret == _pytest.main.EXIT_OK -class TestConfigAPI: +class TestConfigAPI(object): def test_config_trace(self, testdir): config = testdir.parseconfig() l = [] @@ -304,7 +304,7 @@ def test_confcutdir_check_isdir(self, testdir): assert config.getoption('confcutdir') == str(testdir.tmpdir.join('dir')) -class TestConfigFromdictargs: +class TestConfigFromdictargs(object): def test_basic_behavior(self): from _pytest.config import Config option_dict = { @@ -389,19 +389,19 @@ def test_preparse_ordering_with_setuptools(testdir, monkeypatch): def my_iter(name): assert name == "pytest11" - class Dist: + class Dist(object): project_name = 'spam' version = '1.0' def _get_metadata(self, name): return ['foo.txt,sha256=abc,123'] - class EntryPoint: + class EntryPoint(object): name = "mytestplugin" dist = Dist() def load(self): - class PseudoPlugin: + class PseudoPlugin(object): x = 42 return PseudoPlugin() @@ -423,14 +423,14 @@ def test_setuptools_importerror_issue1479(testdir, monkeypatch): def my_iter(name): assert name == "pytest11" - class Dist: + class Dist(object): project_name = 'spam' version = '1.0' def _get_metadata(self, name): return ['foo.txt,sha256=abc,123'] - class EntryPoint: + class EntryPoint(object): name = "mytestplugin" dist = Dist() @@ -450,14 +450,14 @@ def test_plugin_preparse_prevents_setuptools_loading(testdir, monkeypatch): def my_iter(name): assert name == "pytest11" - class Dist: + class Dist(object): project_name = 'spam' version = '1.0' def _get_metadata(self, name): return ['foo.txt,sha256=abc,123'] - class EntryPoint: + class EntryPoint(object): name = "mytestplugin" dist = Dist() @@ -557,7 +557,7 @@ def test_notify_exception(testdir, capfd): out, err = capfd.readouterr() assert "ValueError" in err - class A: + class A(object): def pytest_internalerror(self, excrepr): return True @@ -571,7 +571,7 @@ def test_load_initial_conftest_last_ordering(testdir): from _pytest.config import get_config pm = get_config().pluginmanager - class My: + class My(object): def pytest_load_initial_conftests(self): pass @@ -602,7 +602,7 @@ def test_get_plugin_specs_as_list(): assert _get_plugin_specs_as_list(('foo', 'bar')) == ['foo', 'bar'] -class TestWarning: +class TestWarning(object): def test_warn_config(self, testdir): testdir.makeconftest(""" l = [] @@ -641,7 +641,7 @@ def test_hello(fix): *WT1*test_warn_on_test_item*:7 hello* """) -class TestRootdir: +class TestRootdir(object): def test_simple_noini(self, tmpdir): assert get_common_ancestor([tmpdir]) == tmpdir a = tmpdir.mkdir("a") @@ -699,7 +699,7 @@ def test_with_specific_inifile(self, tmpdir): assert rootdir == tmpdir -class TestOverrideIniArgs: +class TestOverrideIniArgs(object): @pytest.mark.parametrize("name", "setup.cfg tox.ini pytest.ini".split()) def test_override_ini_names(self, testdir, name): testdir.tmpdir.join(name).write(py.std.textwrap.dedent(""" diff --git a/testing/test_conftest.py b/testing/test_conftest.py index c0fa7470178..e9fd1927a95 100644 --- a/testing/test_conftest.py +++ b/testing/test_conftest.py @@ -24,14 +24,14 @@ def ConftestWithSetinitial(path): return conftest def conftest_setinitial(conftest, args, confcutdir=None): - class Namespace: + class Namespace(object): def __init__(self): self.file_or_dir = args self.confcutdir = str(confcutdir) self.noconftest = False conftest._set_initial_conftests(Namespace()) -class TestConftestValueAccessGlobal: +class TestConftestValueAccessGlobal(object): def test_basic_init(self, basedir): conftest = PytestPluginManager() p = basedir.join("adir") @@ -265,7 +265,7 @@ def test_hello(found): """) -class TestConftestVisibility: +class TestConftestVisibility(object): def _setup_tree(self, testdir): # for issue616 # example mostly taken from: # https://mail.python.org/pipermail/pytest-dev/2014-September/002617.html @@ -398,7 +398,7 @@ def out_of_reach(): pass def test_issue1073_conftest_special_objects(testdir): testdir.makeconftest(""" - class DontTouchMe: + class DontTouchMe(object): def __getattr__(self, x): raise Exception('cant touch me') diff --git a/testing/test_doctest.py b/testing/test_doctest.py index d4d9037080c..429bb8de924 100644 --- a/testing/test_doctest.py +++ b/testing/test_doctest.py @@ -6,7 +6,7 @@ import pytest -class TestDoctests: +class TestDoctests(object): def test_collect_testtextfile(self, testdir): w = testdir.maketxtfile(whatever="") @@ -378,7 +378,7 @@ def another(): def test_doctestmodule_two_tests_one_fail(self, testdir): p = testdir.makepyfile(""" - class MyClass: + class MyClass(object): def bad_meth(self): ''' >>> magic = 42 @@ -401,7 +401,7 @@ def test_ignored_whitespace(self, testdir): doctest_optionflags = ELLIPSIS NORMALIZE_WHITESPACE """) p = testdir.makepyfile(""" - class MyClass: + class MyClass(object): ''' >>> a = "foo " >>> print(a) @@ -418,7 +418,7 @@ def test_non_ignored_whitespace(self, testdir): doctest_optionflags = ELLIPSIS """) p = testdir.makepyfile(""" - class MyClass: + class MyClass(object): ''' >>> a = "foo " >>> print(a) @@ -505,7 +505,7 @@ def foo(): reprec.assertoutcome(failed=1) -class TestLiterals: +class TestLiterals(object): @pytest.mark.parametrize('config_mode', ['ini', 'comment']) def test_allow_unicode(self, testdir, config_mode): @@ -592,7 +592,7 @@ def test_bytes_literal(self, testdir): reprec.assertoutcome(passed=passed, failed=int(not passed)) -class TestDoctestSkips: +class TestDoctestSkips(object): """ If all examples in a doctest are skipped due to the SKIP option, then the tests should be SKIPPED rather than PASSED. (#957) @@ -646,7 +646,7 @@ def test_vacuous_all_skipped(self, testdir, makedoctest): reprec.assertoutcome(passed=0, skipped=0) -class TestDoctestAutoUseFixtures: +class TestDoctestAutoUseFixtures(object): SCOPES = ['module', 'session', 'class', 'function'] @@ -765,7 +765,7 @@ def auto(request): result.stdout.fnmatch_lines(['*=== 1 passed in *']) -class TestDoctestNamespaceFixture: +class TestDoctestNamespaceFixture(object): SCOPES = ['module', 'session', 'class', 'function'] @@ -815,7 +815,7 @@ def foo(): reprec.assertoutcome(passed=1) -class TestDoctestReportingOption: +class TestDoctestReportingOption(object): def _run_doctest_report(self, testdir, format): testdir.makepyfile(""" def foo(): diff --git a/testing/test_junitxml.py b/testing/test_junitxml.py index 83256d7c663..70c02332c15 100644 --- a/testing/test_junitxml.py +++ b/testing/test_junitxml.py @@ -79,7 +79,7 @@ def next_siebling(self): return type(self)(self.__node.nextSibling) -class TestPython: +class TestPython(object): def test_summing_simple(self, testdir): testdir.makepyfile(""" import pytest @@ -263,7 +263,7 @@ def test_skip(): def test_classname_instance(self, testdir): testdir.makepyfile(""" - class TestClass: + class TestClass(object): def test_method(self): assert 0 """) @@ -376,7 +376,7 @@ def test_junit_prefixing(self, testdir): testdir.makepyfile(""" def test_func(): assert 0 - class TestHello: + class TestHello(object): def test_hello(self): pass """) @@ -569,7 +569,7 @@ def test_mangle_test_address(): def test_dont_configure_on_slaves(tmpdir): gotten = [] - class FakeConfig: + class FakeConfig(object): def __init__(self): self.pluginmanager = self self.option = self @@ -588,7 +588,7 @@ def __init__(self): assert len(gotten) == 1 -class TestNonPython: +class TestNonPython(object): def test_summing_simple(self, testdir): testdir.makeconftest(""" import pytest @@ -750,7 +750,7 @@ def test_func(param): def test_double_colon_split_method_issue469(testdir): testdir.makepyfile(""" import pytest - class TestClass: + class TestClass(object): @pytest.mark.parametrize('param', ["double::colon"]) def test_func(self, param): pass diff --git a/testing/test_mark.py b/testing/test_mark.py index 5b52e55dbbb..9474d103369 100644 --- a/testing/test_mark.py +++ b/testing/test_mark.py @@ -3,7 +3,7 @@ import py, pytest from _pytest.mark import MarkGenerator as Mark -class TestMark: +class TestMark(object): def test_markinfo_repr(self): from _pytest.mark import MarkInfo, Mark m = MarkInfo(Mark("hello", (1,2), {})) @@ -301,7 +301,7 @@ def test_func(arg): rec.assertoutcome(passed=3) -class TestFunctional: +class TestFunctional(object): def test_mark_per_function(self, testdir): p = testdir.makepyfile(""" @@ -326,7 +326,7 @@ def test_func(): def test_marklist_per_class(self, testdir): item = testdir.getitem(""" import pytest - class TestClass: + class TestClass(object): pytestmark = [pytest.mark.hello, pytest.mark.world] def test_func(self): assert TestClass.test_func.hello @@ -339,7 +339,7 @@ def test_marklist_per_module(self, testdir): item = testdir.getitem(""" import pytest pytestmark = [pytest.mark.hello, pytest.mark.world] - class TestClass: + class TestClass(object): def test_func(self): assert TestClass.test_func.hello assert TestClass.test_func.world @@ -352,7 +352,7 @@ def test_mark_per_class_decorator(self, testdir): item = testdir.getitem(""" import pytest @pytest.mark.hello - class TestClass: + class TestClass(object): def test_func(self): assert TestClass.test_func.hello """) @@ -363,7 +363,7 @@ def test_mark_per_class_decorator_plus_existing_dec(self, testdir): item = testdir.getitem(""" import pytest @pytest.mark.hello - class TestClass: + class TestClass(object): pytestmark = pytest.mark.world def test_func(self): assert TestClass.test_func.hello @@ -377,7 +377,7 @@ def test_merging_markers(self, testdir): p = testdir.makepyfile(""" import pytest pytestmark = pytest.mark.hello("pos1", x=1, y=2) - class TestClass: + class TestClass(object): # classlevel overrides module level pytestmark = pytest.mark.hello(x=3) @pytest.mark.hello("pos0", z=4) @@ -403,11 +403,11 @@ def test_merging_markers_deep(self, testdir): # issue 199 - propagate markers into nested classes p = testdir.makepyfile(""" import pytest - class TestA: + class TestA(object): pytestmark = pytest.mark.a def test_b(self): assert True - class TestC: + class TestC(object): # this one didnt get marked def test_d(self): assert True @@ -422,7 +422,7 @@ def test_mark_decorator_subclass_does_not_propagate_to_base(self, testdir): import pytest @pytest.mark.a - class Base: pass + class Base(object): pass @pytest.mark.b class Test1(Base): @@ -441,7 +441,7 @@ def test_mark_should_not_pass_to_siebling_class(self, testdir): p = testdir.makepyfile(""" import pytest - class TestBase: + class TestBase(object): def test_foo(self): pass @@ -465,7 +465,7 @@ def test_mark_decorator_baseclasses_merged(self, testdir): import pytest @pytest.mark.a - class Base: pass + class Base(object): pass @pytest.mark.b class Base2(Base): pass @@ -485,7 +485,7 @@ def test_bar(self): pass def test_mark_with_wrong_marker(self, testdir): reprec = testdir.inline_runsource(""" import pytest - class pytestmark: + class pytestmark(object): pass def test_func(): pass @@ -630,7 +630,7 @@ def test_1(parameter): reprec.assertoutcome(skipped=1) -class TestKeywordSelection: +class TestKeywordSelection(object): def test_select_simple(self, testdir): file_test = testdir.makepyfile(""" @@ -659,7 +659,7 @@ def test_select_extra_keywords(self, testdir, keyword): p = testdir.makepyfile(test_select=""" def test_1(): pass - class TestClass: + class TestClass(object): def test_2(self): pass """) diff --git a/testing/test_monkeypatch.py b/testing/test_monkeypatch.py index 9d02e2cc0b6..04a53d93ad8 100644 --- a/testing/test_monkeypatch.py +++ b/testing/test_monkeypatch.py @@ -16,7 +16,7 @@ def mp(): def test_setattr(): - class A: + class A(object): x = 1 monkeypatch = MonkeyPatch() @@ -39,7 +39,7 @@ class A: assert A.x == 5 -class TestSetattrWithImportPath: +class TestSetattrWithImportPath(object): def test_string_expression(self, monkeypatch): monkeypatch.setattr("os.path.abspath", lambda x: "hello2") assert os.path.abspath("123") == "hello2" @@ -79,7 +79,7 @@ def test_delattr(self, monkeypatch): def test_delattr(): - class A: + class A(object): x = 1 monkeypatch = MonkeyPatch() @@ -294,7 +294,7 @@ class SampleNewInherit(SampleNew): pass -class SampleOld: +class SampleOld(object): # oldstyle on python2 @staticmethod def hello(): diff --git a/testing/test_nose.py b/testing/test_nose.py index f542461114c..11fb8317610 100644 --- a/testing/test_nose.py +++ b/testing/test_nose.py @@ -26,7 +26,7 @@ def test_setup_func_with_setup_decorator(): from _pytest.nose import call_optional l = [] - class A: + class A(object): @pytest.fixture(autouse=True) def f(self): l.append(1) @@ -38,7 +38,7 @@ def f(self): def test_setup_func_not_callable(): from _pytest.nose import call_optional - class A: + class A(object): f = 1 call_optional(A(), "f") @@ -270,7 +270,7 @@ def test_nose_setup_ordering(testdir): def setup_module(mod): mod.visited = True - class TestClass: + class TestClass(object): def setup(self): assert visited def test_first(self): @@ -377,7 +377,7 @@ def test_istest_class_decorator(testdir): p = testdir.makepyfile(""" import nose.tools @nose.tools.istest - class NotTestPrefix: + class NotTestPrefix(object): def test_method(self): pass """) @@ -388,7 +388,7 @@ def test_nottest_class_decorator(testdir): testdir.makepyfile(""" import nose.tools @nose.tools.nottest - class TestPrefix: + class TestPrefix(object): def test_method(self): pass """) diff --git a/testing/test_parseopt.py b/testing/test_parseopt.py index e933dbb8d4c..03d71de4350 100644 --- a/testing/test_parseopt.py +++ b/testing/test_parseopt.py @@ -8,7 +8,7 @@ def parser(): return parseopt.Parser() -class TestParser: +class TestParser(object): def test_no_help_by_default(self, capsys): parser = parseopt.Parser(usage="xyz") pytest.raises(SystemExit, lambda: parser.parse(["-h"])) @@ -139,7 +139,7 @@ def test_parse_setoption(self, parser): parser.addoption("--hello", dest="hello", action="store") parser.addoption("--world", dest="world", default=42) - class A: + class A(object): pass option = A() diff --git a/testing/test_pastebin.py b/testing/test_pastebin.py index 8123424ca89..f0d2a9ba2f7 100644 --- a/testing/test_pastebin.py +++ b/testing/test_pastebin.py @@ -2,7 +2,7 @@ import sys import pytest -class TestPasteCapture: +class TestPasteCapture(object): @pytest.fixture def pastebinlist(self, monkeypatch, request): @@ -71,7 +71,7 @@ def test(): ]) -class TestPaste: +class TestPaste(object): @pytest.fixture def pastebin(self, request): @@ -88,7 +88,7 @@ def mocked_urlopen(self, monkeypatch): def mocked(url, data): calls.append((url, data)) - class DummyFile: + class DummyFile(object): def read(self): # part of html of a normal response return b'View raw.' diff --git a/testing/test_pdb.py b/testing/test_pdb.py index 63a0c2f00b3..cf6d6f7fb8d 100644 --- a/testing/test_pdb.py +++ b/testing/test_pdb.py @@ -18,7 +18,7 @@ def custom_pdb_calls(): called = [] # install dummy debugger class and track which methods were called on it - class _CustomPdb: + class _CustomPdb(object): def __init__(self, *args, **kwargs): called.append("init") @@ -33,7 +33,7 @@ def interaction(self, *args): -class TestPDB: +class TestPDB(object): @pytest.fixture def pdblist(self, request): @@ -374,7 +374,7 @@ def test_pdb_custom_cls_without_pdb(self, testdir, custom_pdb_calls): def test_pdb_custom_cls_with_settrace(self, testdir, monkeypatch): testdir.makepyfile(custom_pdb=""" - class CustomPdb: + class CustomPdb(object): def set_trace(*args, **kwargs): print 'custom set_trace>' """) diff --git a/testing/test_pluginmanager.py b/testing/test_pluginmanager.py index 45ad321a392..3214d868b0b 100644 --- a/testing/test_pluginmanager.py +++ b/testing/test_pluginmanager.py @@ -11,7 +11,7 @@ def pytestpm(): return PytestPluginManager() -class TestPytestPluginInteractions: +class TestPytestPluginInteractions(object): def test_addhooks_conftestplugin(self, testdir): testdir.makepyfile(newhooks=""" def pytest_myhook(xyz): @@ -85,7 +85,7 @@ def test_configure(self, testdir): config = testdir.parseconfig() l = [] - class A: + class A(object): def pytest_configure(self, config): l.append(self) @@ -105,11 +105,11 @@ def test_hook_tracing(self): pytestpm = get_config().pluginmanager # fully initialized with plugins saveindent = [] - class api1: + class api1(object): def pytest_plugin_registered(self): saveindent.append(pytestpm.trace.root.indent) - class api2: + class api2(object): def pytest_plugin_registered(self): saveindent.append(pytestpm.trace.root.indent) raise ValueError() @@ -156,11 +156,11 @@ def test_hook_proxy(self, testdir): def test_warn_on_deprecated_multicall(self, pytestpm): warnings = [] - class get_warnings: + class get_warnings(object): def pytest_logwarning(self, message): warnings.append(message) - class Plugin: + class Plugin(object): def pytest_configure(self, __multicall__): pass @@ -173,11 +173,11 @@ def pytest_configure(self, __multicall__): def test_warn_on_deprecated_addhooks(self, pytestpm): warnings = [] - class get_warnings: + class get_warnings(object): def pytest_logwarning(self, code, fslocation, message, nodeid): warnings.append(message) - class Plugin: + class Plugin(object): def pytest_testhook(): pass @@ -221,7 +221,7 @@ def test_importplugin_error_message(testdir, pytestpm): assert py.std.re.match(expected, str(excinfo.value)) -class TestPytestPluginManager: +class TestPytestPluginManager(object): def test_register_imported_modules(self): pm = PytestPluginManager() mod = py.std.types.ModuleType("x.y.pytest_hello") @@ -348,7 +348,7 @@ def test_consider_conftest_deps(self, testdir, pytestpm): pytestpm.consider_conftest(mod) -class TestPytestPluginManagerBootstrapming: +class TestPytestPluginManagerBootstrapming(object): def test_preparse_args(self, pytestpm): pytest.raises(ImportError, lambda: pytestpm.consider_preparse(["xyz", "-p", "hello123"])) diff --git a/testing/test_pytester.py b/testing/test_pytester.py index 49cf43a3eff..9c9b5637157 100644 --- a/testing/test_pytester.py +++ b/testing/test_pytester.py @@ -12,7 +12,7 @@ def test_make_hook_recorder(testdir): pytest.xfail("internal reportrecorder tests need refactoring") - class rep: + class rep(object): excinfo = None passed = False failed = True @@ -25,7 +25,7 @@ class rep: failures = recorder.getfailures() assert failures == [rep] - class rep: + class rep(object): excinfo = None passed = False failed = False @@ -74,7 +74,7 @@ def test_hello(testdir): def make_holder(): - class apiclass: + class apiclass(object): def pytest_xyz(self, arg): "x" def pytest_xyz_noarg(self): diff --git a/testing/test_resultlog.py b/testing/test_resultlog.py index e2d4fc26367..c2f4a801c2d 100644 --- a/testing/test_resultlog.py +++ b/testing/test_resultlog.py @@ -70,7 +70,7 @@ def test_write_log_entry(): assert entry_lines[1:] == [' '+line for line in longrepr.splitlines()] -class TestWithFunctionIntegration: +class TestWithFunctionIntegration(object): # XXX (hpk) i think that the resultlog plugin should # provide a Parser object so that one can remain # ignorant regarding formatting details. diff --git a/testing/test_runner.py b/testing/test_runner.py index 727defa9252..265e99d549b 100644 --- a/testing/test_runner.py +++ b/testing/test_runner.py @@ -8,7 +8,7 @@ import sys from _pytest import runner, main -class TestSetupState: +class TestSetupState(object): def test_setup(self, testdir): ss = runner.SetupState() item = testdir.getitem("def test_func(): pass") @@ -71,7 +71,7 @@ def fin2(): raise Exception('oops2') assert err.value.args == ('oops2',) -class BaseFunctionalTests: +class BaseFunctionalTests(object): def test_passfunction(self, testdir): reports = testdir.runitem(""" def test_func(): @@ -200,7 +200,7 @@ def test_exact_teardown_issue90(self, testdir): rec = testdir.inline_runsource(""" import pytest - class TestClass: + class TestClass(object): def test_method(self): pass def teardown_class(cls): @@ -239,7 +239,7 @@ def test_exact_teardown_issue1206(self, testdir): rec = testdir.inline_runsource(""" import pytest - class TestClass: + class TestClass(object): def teardown_method(self, x, y, z): pass @@ -351,12 +351,12 @@ def test_func(): assert rep.failed assert rep.when == "???" -class TestSessionReports: +class TestSessionReports(object): def test_collect_result(self, testdir): col = testdir.getmodulecol(""" def test_func1(): pass - class TestClass: + class TestClass(object): pass """) rep = runner.collect_one_node(col) @@ -409,7 +409,7 @@ def test_runtest_in_module_ordering(testdir): import pytest def pytest_runtest_setup(item): # runs after class-level! item.function.mylist.append("module") - class TestClass: + class TestClass(object): def pytest_runtest_setup(self, item): assert not hasattr(item.function, 'mylist') item.function.mylist = ['class'] @@ -680,7 +680,7 @@ def test_store_except_info_on_eror(): sys.last_traceback and friends. """ # Simulate item that raises a specific exception - class ItemThatRaises: + class ItemThatRaises(object): def runtest(self): raise IndexError('TEST') try: @@ -693,7 +693,7 @@ def runtest(self): assert sys.last_traceback -class TestReportContents: +class TestReportContents(object): """ Test user-level API of ``TestReport`` objects. """ diff --git a/testing/test_runner_xunit.py b/testing/test_runner_xunit.py index e1f0924c6d6..9bf15bd668d 100644 --- a/testing/test_runner_xunit.py +++ b/testing/test_runner_xunit.py @@ -24,7 +24,7 @@ def test_modlevel(): assert modlevel[0] == 42 assert test_modlevel.answer == 17 - class TestFromClass: + class TestFromClass(object): def test_module(self): assert modlevel[0] == 42 assert not hasattr(test_modlevel, 'answer') @@ -69,7 +69,7 @@ def test_func(): def test_class_setup(testdir): reprec = testdir.inline_runsource(""" - class TestSimpleClassSetup: + class TestSimpleClassSetup(object): clslevel = [] def setup_class(cls): cls.clslevel.append(23) @@ -92,7 +92,7 @@ def test_cleanup(): def test_class_setup_failure_no_teardown(testdir): reprec = testdir.inline_runsource(""" - class TestSimpleClassSetup: + class TestSimpleClassSetup(object): clslevel = [] def setup_class(cls): 0/0 @@ -110,7 +110,7 @@ def test_cleanup(): def test_method_setup(testdir): reprec = testdir.inline_runsource(""" - class TestSetupMethod: + class TestSetupMethod(object): def setup_method(self, meth): self.methsetup = meth def teardown_method(self, meth): @@ -126,7 +126,7 @@ def test_other(self): def test_method_setup_failure_no_teardown(testdir): reprec = testdir.inline_runsource(""" - class TestMethodSetup: + class TestMethodSetup(object): clslevel = [] def setup_method(self, method): self.clslevel.append(1) @@ -145,7 +145,7 @@ def test_cleanup(): def test_method_generator_setup(testdir): reprec = testdir.inline_runsource(""" - class TestSetupTeardownOnInstance: + class TestSetupTeardownOnInstance(object): def setup_class(cls): cls.classsetup = True @@ -195,7 +195,7 @@ def check(): def test_method_setup_uses_fresh_instances(testdir): reprec = testdir.inline_runsource(""" - class TestSelfState1: + class TestSelfState1(object): memory = [] def test_hello(self): self.memory.append(self) @@ -276,7 +276,7 @@ def teardown_function({arg}): trace('teardown_function') def test_function_1(): pass def test_function_2(): pass - class Test: + class Test(object): def setup_method(self, {arg}): trace('setup_method') def teardown_method(self, {arg}): trace('teardown_method') diff --git a/testing/test_session.py b/testing/test_session.py index a7dcb27a4e1..b6e7d2b6c6c 100644 --- a/testing/test_session.py +++ b/testing/test_session.py @@ -2,7 +2,7 @@ from _pytest.main import EXIT_NOTESTSCOLLECTED -class SessionTests: +class SessionTests(object): def test_basic_testitem_events(self, testdir): tfile = testdir.makepyfile(""" def test_one(): @@ -11,7 +11,7 @@ def test_one_one(): assert 0 def test_other(): raise ValueError(23) - class TestClass: + class TestClass(object): def test_two(self, someargs): pass """) @@ -97,12 +97,12 @@ def test_three(): assert 0 def test_broken_repr(self, testdir): p = testdir.makepyfile(""" import pytest - class BrokenRepr1: + class BrokenRepr1(object): foo=0 def __repr__(self): raise Exception("Ha Ha fooled you, I'm a broken repr().") - class TestBrokenClass: + class TestBrokenClass(object): def test_explicit_bad_repr(self): t = BrokenRepr1() pytest.raises(Exception, 'repr(t)') @@ -145,7 +145,7 @@ def test_2(): l.append(2) def test_3(): assert l == [1,2] - class Testmygroup: + class Testmygroup(object): reslist = l def test_1(self): self.reslist.append(1) @@ -167,7 +167,7 @@ def test_collect_only_with_various_situations(self, testdir): def test_one(): raise ValueError() - class TestX: + class TestX(object): def test_method_one(self): pass diff --git a/testing/test_skipping.py b/testing/test_skipping.py index 2e7868d3ab8..6a8d147ad4f 100644 --- a/testing/test_skipping.py +++ b/testing/test_skipping.py @@ -5,7 +5,7 @@ from _pytest.runner import runtestprotocol -class TestEvaluator: +class TestEvaluator(object): def test_no_marker(self, testdir): item = testdir.getitem("def test_func(): pass") evalskipif = MarkEvaluator(item, 'skipif') @@ -114,7 +114,7 @@ def test_func(): def test_skipif_class(self, testdir): item, = testdir.getitems(""" import pytest - class TestClass: + class TestClass(object): pytestmark = pytest.mark.skipif("config._hackxyz") def test_func(self): pass @@ -126,7 +126,7 @@ def test_func(self): assert expl == "condition: config._hackxyz" -class TestXFail: +class TestXFail(object): @pytest.mark.parametrize('strict', [True, False]) def test_xfail_simple(self, testdir, strict): @@ -452,7 +452,7 @@ def test_foo(): assert result.ret == (1 if strict else 0) -class TestXFailwithSetupTeardown: +class TestXFailwithSetupTeardown(object): def test_failing_setup_issue9(self, testdir): testdir.makepyfile(""" import pytest @@ -484,7 +484,7 @@ def test_func(): ]) -class TestSkip: +class TestSkip(object): def test_skip_class(self, testdir): testdir.makepyfile(""" import pytest @@ -581,7 +581,7 @@ def test_hello(): "*1 skipped*", ]) -class TestSkipif: +class TestSkipif(object): def test_skipif_conditional(self, testdir): item = testdir.getitem(""" import pytest @@ -648,7 +648,7 @@ def test_skipif_class(testdir): p = testdir.makepyfile(""" import pytest - class TestClass: + class TestClass(object): pytestmark = pytest.mark.skipif("True") def test_that(self): assert 0 @@ -667,7 +667,7 @@ def test_skip_reasons_folding(): message = "justso" longrepr = (path, lineno, message) - class X: + class X(object): pass ev1 = X() ev1.when = "execute" @@ -694,7 +694,7 @@ def setup_function(func): doskip() def test_func(): pass - class TestClass: + class TestClass(object): def test_method(self): doskip() """, @@ -892,7 +892,7 @@ def pytest_runtest_setup(item): *2 skipped* """) -class TestBooleanCondition: +class TestBooleanCondition(object): def test_skipif(self, testdir): testdir.makepyfile(""" import pytest diff --git a/testing/test_terminal.py b/testing/test_terminal.py index 3efd7b1f90a..77fb3b15417 100644 --- a/testing/test_terminal.py +++ b/testing/test_terminal.py @@ -16,7 +16,7 @@ DistInfo = collections.namedtuple('DistInfo', ['project_name', 'version']) -class Option: +class Option(object): def __init__(self, verbose=False, fulltrace=False): self.verbose = verbose self.fulltrace = fulltrace @@ -56,7 +56,7 @@ def test_plugin_nameversion(input, expected): assert result == expected -class TestTerminal: +class TestTerminal(object): def test_pass_skip_fail(self, testdir, option): testdir.makepyfile(""" import pytest @@ -127,7 +127,7 @@ def test_1(): def test_itemreport_subclasses_show_subclassed_file(self, testdir): testdir.makepyfile(test_p1=""" - class BaseTests: + class BaseTests(object): def test_p1(self): pass class TestClass(BaseTests): @@ -151,7 +151,7 @@ class TestMore(BaseTests): def test_itemreport_directclasses_not_shown_as_subclasses(self, testdir): a = testdir.mkpydir("a123") a.join("test_hello123.py").write(_pytest._code.Source(""" - class TestClass: + class TestClass(object): def test_method(self): pass """)) @@ -204,7 +204,7 @@ def test_foobar(): result.stdout.fnmatch_lines(['*KeyboardInterrupt*']) -class TestCollectonly: +class TestCollectonly(object): def test_collectonly_basic(self, testdir): testdir.makepyfile(""" def test_func(): @@ -249,7 +249,7 @@ def test_collectonly_simple(self, testdir): p = testdir.makepyfile(""" def test_func1(): pass - class TestClass: + class TestClass(object): def test_method(self): pass """) @@ -310,7 +310,7 @@ def test_repr_python_version(monkeypatch): finally: monkeypatch.undo() # do this early as pytest can get confused -class TestFixtureReporting: +class TestFixtureReporting(object): def test_setup_fixture_error(self, testdir): testdir.makepyfile(""" def setup_function(function): @@ -395,7 +395,7 @@ def teardown_function(function): "*1 failed*", ]) -class TestTerminalFunctional: +class TestTerminalFunctional(object): def test_deselected(self, testdir): testpath = testdir.makepyfile(""" def test_one(): @@ -431,7 +431,7 @@ def test_passes(self, testdir): p1 = testdir.makepyfile(""" def test_passes(): pass - class TestClass: + class TestClass(object): def test_method(self): pass """) @@ -487,7 +487,7 @@ def test_fail(): raise ValueError() def test_pass(): pass - class TestClass: + class TestClass(object): def test_skip(self): pytest.skip("hello") def test_gen(): @@ -612,8 +612,8 @@ def test_this(i): def test_getreportopt(): - class config: - class option: + class config(object): + class option(object): reportchars = "" disablepytestwarnings = True @@ -683,7 +683,7 @@ def test_traceconfig(testdir, monkeypatch): assert result.ret == EXIT_NOTESTSCOLLECTED -class TestGenericReporting: +class TestGenericReporting(object): """ this test class can be subclassed with a different option provider to run e.g. distributed tests. """ diff --git a/testing/test_tmpdir.py b/testing/test_tmpdir.py index 232acb6d232..32ac7633170 100644 --- a/testing/test_tmpdir.py +++ b/testing/test_tmpdir.py @@ -34,7 +34,7 @@ def test_ensuretemp(recwarn): assert d1 == d2 assert d1.check(dir=1) -class TestTempdirHandler: +class TestTempdirHandler(object): def test_mktemp(self, testdir): from _pytest.tmpdir import TempdirFactory config = testdir.parseconfig() @@ -48,7 +48,7 @@ def test_mktemp(self, testdir): assert tmp2.relto(t.getbasetemp()).startswith("this") assert tmp2 != tmp -class TestConfigTmpdir: +class TestConfigTmpdir(object): def test_getbasetemp_custom_removes_old(self, testdir): mytemp = testdir.tmpdir.join("xyz") p = testdir.makepyfile(""" diff --git a/testing/test_unittest.py b/testing/test_unittest.py index 9625ae0f853..832ea08ccff 100644 --- a/testing/test_unittest.py +++ b/testing/test_unittest.py @@ -385,7 +385,7 @@ def test_func(self): reprec.assertoutcome(skipped=1) -class TestTrialUnittest: +class TestTrialUnittest(object): def setup_class(cls): cls.ut = pytest.importorskip("twisted.trial.unittest") @@ -704,7 +704,7 @@ def test_classattr(self): def test_non_unittest_no_setupclass_support(testdir): testpath = testdir.makepyfile(""" - class TestFoo: + class TestFoo(object): x = 0 @classmethod