diff --git a/_pytest/_argcomplete.py b/_pytest/_argcomplete.py index 0625a75f9..ea8c98c7f 100644 --- a/_pytest/_argcomplete.py +++ b/_pytest/_argcomplete.py @@ -60,7 +60,7 @@ import os from glob import glob -class FastFilesCompleter: +class FastFilesCompleter(object): 'Fast file completer class' def __init__(self, directories=True): diff --git a/_pytest/assertion/__init__.py b/_pytest/assertion/__init__.py index a48e98c85..39c57c5f3 100644 --- a/_pytest/assertion/__init__.py +++ b/_pytest/assertion/__init__.py @@ -56,7 +56,7 @@ class DummyRewriteHook(object): pass -class AssertionState: +class AssertionState(object): """State for the assertion plugin.""" def __init__(self, config, mode): diff --git a/_pytest/cacheprovider.py b/_pytest/cacheprovider.py index c537c1447..0db08a1aa 100755 --- a/_pytest/cacheprovider.py +++ b/_pytest/cacheprovider.py @@ -98,7 +98,7 @@ class Cache(object): json.dump(value, f, indent=2, sort_keys=True) -class LFPlugin: +class LFPlugin(object): """ Plugin which implements the --lf (run last-failing) option """ def __init__(self, config): diff --git a/_pytest/capture.py b/_pytest/capture.py index f2ebe38c8..36658acce 100644 --- a/_pytest/capture.py +++ b/_pytest/capture.py @@ -61,7 +61,7 @@ def pytest_load_initial_conftests(early_config, parser, args): sys.stderr.write(err) -class CaptureManager: +class CaptureManager(object): """ Capture plugin, manages that the appropriate capture method is enabled/disabled during collection and each test phase (setup, call, teardown). After each of those points, the captured output is obtained and @@ -271,7 +271,7 @@ def _install_capture_fixture_on_item(request, capture_class): del request.node._capture_fixture -class CaptureFixture: +class CaptureFixture(object): def __init__(self, captureclass, request): self.captureclass = captureclass self.request = request @@ -416,11 +416,11 @@ class MultiCapture(object): self.err.snap() if self.err is not None else "") -class NoCapture: +class NoCapture(object): __init__ = start = done = suspend = resume = lambda *args: None -class FDCaptureBinary: +class FDCaptureBinary(object): """Capture IO to/from a given os-level filedescriptor. snap() produces `bytes` @@ -506,7 +506,7 @@ class FDCapture(FDCaptureBinary): return res -class SysCapture: +class SysCapture(object): def __init__(self, fd, tmpfile=None): name = patchsysdict[fd] self._old = getattr(sys, name) @@ -551,7 +551,7 @@ class SysCaptureBinary(SysCapture): return res -class DontReadFromInput: +class DontReadFromInput(object): """Temporary stub class. Ideally when stdin is accessed, the capturing should be turned off, with possibly all data captured so far sent to the screen. This should be configurable, though, diff --git a/_pytest/config.py b/_pytest/config.py index 22bf6c60c..24887a5f3 100644 --- a/_pytest/config.py +++ b/_pytest/config.py @@ -66,7 +66,7 @@ def main(args=None, plugins=None): return 4 -class cmdline: # compatibility namespace +class cmdline(object): # compatibility namespace main = staticmethod(main) @@ -463,7 +463,7 @@ def _get_plugin_specs_as_list(specs): return [] -class Parser: +class Parser(object): """ Parser for command line arguments and ini-file values. :ivar extra_info: dict of generic param -> value to display in case @@ -598,7 +598,7 @@ class ArgumentError(Exception): return self.msg -class Argument: +class Argument(object): """class that mimics the necessary behaviour of optparse.Option its currently a least effort implementation @@ -728,7 +728,7 @@ class Argument: return 'Argument({0})'.format(', '.join(args)) -class OptionGroup: +class OptionGroup(object): def __init__(self, name, description="", parser=None): self.name = name self.description = description @@ -859,7 +859,7 @@ class CmdOptions(object): return CmdOptions(self.__dict__) -class Notset: +class Notset(object): def __repr__(self): return "" diff --git a/_pytest/debugging.py b/_pytest/debugging.py index d7dca7809..23d94e688 100644 --- a/_pytest/debugging.py +++ b/_pytest/debugging.py @@ -40,7 +40,7 @@ def pytest_configure(config): config._cleanup.append(fin) -class pytestPDB: +class pytestPDB(object): """ Pseudo PDB that defers to the real pdb. """ _pluginmanager = None _config = None @@ -62,7 +62,7 @@ class pytestPDB: cls._pdb_cls().set_trace(frame) -class PdbInvoke: +class PdbInvoke(object): def pytest_exception_interact(self, node, call, report): capman = node.config.pluginmanager.getplugin("capturemanager") if capman: diff --git a/_pytest/fixtures.py b/_pytest/fixtures.py index a2b6f7d94..b899736e1 100644 --- a/_pytest/fixtures.py +++ b/_pytest/fixtures.py @@ -247,7 +247,7 @@ def get_direct_param_fixture_func(request): return request.param -class FuncFixtureInfo: +class FuncFixtureInfo(object): def __init__(self, argnames, names_closure, name2fixturedefs): self.argnames = argnames self.names_closure = names_closure @@ -443,7 +443,7 @@ class FixtureRequest(FuncargnamesCompatAttr): fixturedef = self._getnextfixturedef(argname) except FixtureLookupError: if argname == "request": - class PseudoFixtureDef: + class PseudoFixtureDef(object): cached_result = (self, [0], None) scope = "function" return PseudoFixtureDef @@ -719,7 +719,7 @@ def call_fixture_func(fixturefunc, request, kwargs): return res -class FixtureDef: +class FixtureDef(object): """ A container for a factory definition. """ def __init__(self, fixturemanager, baseid, argname, func, scope, params, @@ -925,7 +925,7 @@ def pytestconfig(request): return request.config -class FixtureManager: +class FixtureManager(object): """ pytest fixtures definitions and information is stored and managed from this class. diff --git a/_pytest/main.py b/_pytest/main.py index fce4f35f3..1caa7ff1e 100644 --- a/_pytest/main.py +++ b/_pytest/main.py @@ -243,7 +243,7 @@ def _patched_find_module(): yield -class FSHookProxy: +class FSHookProxy(object): def __init__(self, fspath, pm, remove_mods): self.fspath = fspath self.pm = pm diff --git a/_pytest/mark.py b/_pytest/mark.py index 6d095a592..45182bdcd 100644 --- a/_pytest/mark.py +++ b/_pytest/mark.py @@ -284,7 +284,7 @@ def pytest_unconfigure(config): MARK_GEN._config = getattr(config, '_old_mark_config', None) -class MarkGenerator: +class MarkGenerator(object): """ Factory for :class:`MarkDecorator` objects - exposed as a ``pytest.mark`` singleton instance. Example:: diff --git a/_pytest/monkeypatch.py b/_pytest/monkeypatch.py index 40ae560f0..c402213e8 100644 --- a/_pytest/monkeypatch.py +++ b/_pytest/monkeypatch.py @@ -88,7 +88,7 @@ def derive_importpath(import_path, raising): return attr, target -class Notset: +class Notset(object): def __repr__(self): return "" @@ -96,7 +96,7 @@ class Notset: notset = Notset() -class MonkeyPatch: +class MonkeyPatch(object): """ Object returned by the ``monkeypatch`` fixture keeping a record of setattr/item/env/syspath changes. """ diff --git a/_pytest/pytester.py b/_pytest/pytester.py index 1ea851785..c14a34d7e 100644 --- a/_pytest/pytester.py +++ b/_pytest/pytester.py @@ -171,7 +171,7 @@ def _pytest(request): return PytestArg(request) -class PytestArg: +class PytestArg(object): def __init__(self, request): self.request = request @@ -186,7 +186,7 @@ def get_public_names(values): return [x for x in values if x[0] != "_"] -class ParsedCall: +class ParsedCall(object): def __init__(self, name, kwargs): self.__dict__.update(kwargs) self._name = name @@ -197,7 +197,7 @@ class ParsedCall: return "" % (self._name, d) -class HookRecorder: +class HookRecorder(object): """Record all hooks called in a plugin manager. This wraps all the hook calls in the plugin manager, recording each call @@ -343,7 +343,7 @@ def testdir(request, tmpdir_factory): rex_outcome = re.compile(r"(\d+) ([\w-]+)") -class RunResult: +class RunResult(object): """The result of running a command. Attributes: @@ -397,7 +397,7 @@ class RunResult: assert obtained == dict(passed=passed, skipped=skipped, failed=failed, error=error) -class CwdSnapshot: +class CwdSnapshot(object): def __init__(self): self.__saved = os.getcwd() @@ -405,7 +405,7 @@ class CwdSnapshot: os.chdir(self.__saved) -class SysModulesSnapshot: +class SysModulesSnapshot(object): def __init__(self, preserve=None): self.__preserve = preserve self.__saved = dict(sys.modules) @@ -418,7 +418,7 @@ class SysModulesSnapshot: sys.modules.update(self.__saved) -class SysPathsSnapshot: +class SysPathsSnapshot(object): def __init__(self): self.__saved = list(sys.path), list(sys.meta_path) @@ -426,7 +426,7 @@ class SysPathsSnapshot: sys.path[:], sys.meta_path[:] = self.__saved -class Testdir: +class Testdir(object): """Temporary test directory with tools to test/run pytest itself. This is based on the ``tmpdir`` fixture but provides a number of methods @@ -740,7 +740,7 @@ class Testdir: rec = [] - class Collect: + class Collect(object): def pytest_configure(x, config): rec.append(self.make_hook_recorder(config.pluginmanager)) @@ -750,7 +750,7 @@ class Testdir: if len(rec) == 1: reprec = rec.pop() else: - class reprec: + class reprec(object): pass reprec.ret = ret @@ -780,13 +780,13 @@ class Testdir: reprec = self.inline_run(*args, **kwargs) except SystemExit as e: - class reprec: + class reprec(object): ret = e.args[0] except Exception: traceback.print_exc() - class reprec: + class reprec(object): ret = 3 finally: out, err = capture.readouterr() @@ -1067,7 +1067,7 @@ def getdecoded(out): py.io.saferepr(out),) -class LineComp: +class LineComp(object): def __init__(self): self.stringio = py.io.TextIO() @@ -1085,7 +1085,7 @@ class LineComp: return LineMatcher(lines1).fnmatch_lines(lines2) -class LineMatcher: +class LineMatcher(object): """Flexible matching of text. This is a convenience class to test large texts like the output of diff --git a/_pytest/runner.py b/_pytest/runner.py index 13abee367..d82865b76 100644 --- a/_pytest/runner.py +++ b/_pytest/runner.py @@ -178,7 +178,7 @@ def call_runtest_hook(item, when, **kwds): return CallInfo(lambda: ihook(item=item, **kwds), when=when) -class CallInfo: +class CallInfo(object): """ Result/Exception info a function invocation. """ #: None or ExceptionInfo object. excinfo = None diff --git a/_pytest/terminal.py b/_pytest/terminal.py index f0a2fa618..51d21cb33 100644 --- a/_pytest/terminal.py +++ b/_pytest/terminal.py @@ -94,7 +94,7 @@ def pytest_report_teststatus(report): return report.outcome, letter, report.outcome.upper() -class WarningReport: +class WarningReport(object): """ Simple structure to hold warnings information captured by ``pytest_logwarning``. """ @@ -129,7 +129,7 @@ class WarningReport: return None -class TerminalReporter: +class TerminalReporter(object): def __init__(self, config, file=None): import _pytest.config self.config = config diff --git a/_pytest/tmpdir.py b/_pytest/tmpdir.py index da1b03223..66b4a2d2f 100644 --- a/_pytest/tmpdir.py +++ b/_pytest/tmpdir.py @@ -8,7 +8,7 @@ import py from _pytest.monkeypatch import MonkeyPatch -class TempdirFactory: +class TempdirFactory(object): """Factory for temporary directories under the common base temp directory. The base directory can be configured using the ``--basetemp`` option. diff --git a/changelog/2147.removal b/changelog/2147.removal new file mode 100644 index 000000000..8d2cfed51 --- /dev/null +++ b/changelog/2147.removal @@ -0,0 +1 @@ +All pytest classes now subclass ``object`` for better Python 3 compatibility. This should not affect user code except in very rare edge cases. diff --git a/testing/acceptance_test.py b/testing/acceptance_test.py index 729e93b7f..49bd3a5cd 100644 --- a/testing/acceptance_test.py +++ b/testing/acceptance_test.py @@ -901,7 +901,7 @@ def test_deferred_hook_checking(testdir): testdir.syspathinsert() testdir.makepyfile(**{ 'plugin.py': """ - class Hooks: + class Hooks(object): def pytest_my_hook(self, config): pass diff --git a/testing/python/collect.py b/testing/python/collect.py index 815fb5467..437ec7d5e 100644 --- a/testing/python/collect.py +++ b/testing/python/collect.py @@ -880,10 +880,10 @@ class TestConftestCustomization(object): import sys, os, imp from _pytest.python import Module - class Loader: + class Loader(object): def load_module(self, name): return imp.load_source(name, name + ".narf") - class Finder: + class Finder(object): def find_module(self, name, path=None): if os.path.exists(name + ".narf"): return Loader() diff --git a/testing/python/fixture.py b/testing/python/fixture.py index b159e8ebb..d22389e71 100644 --- a/testing/python/fixture.py +++ b/testing/python/fixture.py @@ -2828,7 +2828,7 @@ class TestShowFixtures(object): def test_show_fixtures_indented_in_class(self, testdir): p = testdir.makepyfile(dedent(''' import pytest - class TestClass: + class TestClass(object): @pytest.fixture def fixture1(self): """line1 diff --git a/testing/python/metafunc.py b/testing/python/metafunc.py index 0ed9f56bf..06979681a 100644 --- a/testing/python/metafunc.py +++ b/testing/python/metafunc.py @@ -241,7 +241,7 @@ class TestMetafunc(object): """ from _pytest.python import _idval - class TestClass: + class TestClass(object): pass def test_function(): diff --git a/testing/test_capture.py b/testing/test_capture.py index f769a725d..69afa0f9c 100644 --- a/testing/test_capture.py +++ b/testing/test_capture.py @@ -1245,7 +1245,7 @@ def test_py36_windowsconsoleio_workaround_non_standard_streams(): """ from _pytest.capture import _py36_windowsconsoleio_workaround - class DummyStream: + class DummyStream(object): def write(self, s): pass diff --git a/testing/test_pytester.py b/testing/test_pytester.py index dd39d31ea..87063371a 100644 --- a/testing/test_pytester.py +++ b/testing/test_pytester.py @@ -135,7 +135,7 @@ def test_makepyfile_utf8(testdir): assert u"mixed_encoding = u'São Paulo'".encode('utf-8') in p.read('rb') -class TestInlineRunModulesCleanup: +class TestInlineRunModulesCleanup(object): def test_inline_run_test_module_not_cleaned_up(self, testdir): test_mod = testdir.makepyfile("def test_foo(): assert True") result = testdir.inline_run(str(test_mod)) @@ -146,7 +146,7 @@ class TestInlineRunModulesCleanup: assert result2.ret == EXIT_TESTSFAILED def spy_factory(self): - class SysModulesSnapshotSpy: + class SysModulesSnapshotSpy(object): instances = [] def __init__(self, preserve=None): @@ -223,7 +223,7 @@ def test_inline_run_clean_sys_paths(testdir): assert sys.meta_path == original_meta_path def spy_factory(self): - class SysPathsSnapshotSpy: + class SysPathsSnapshotSpy(object): instances = [] def __init__(self): @@ -266,7 +266,7 @@ def test_cwd_snapshot(tmpdir): assert py.path.local() == foo -class TestSysModulesSnapshot: +class TestSysModulesSnapshot(object): key = 'my-test-module' def test_remove_added(self): @@ -329,7 +329,7 @@ class TestSysModulesSnapshot: @pytest.mark.parametrize('path_type', ('path', 'meta_path')) -class TestSysPathsSnapshot: +class TestSysPathsSnapshot(object): other_path = { 'path': 'meta_path', 'meta_path': 'path'} diff --git a/testing/test_terminal.py b/testing/test_terminal.py index 7dfa4b01e..574372da4 100644 --- a/testing/test_terminal.py +++ b/testing/test_terminal.py @@ -966,7 +966,7 @@ def test_no_trailing_whitespace_after_inifile_word(testdir): assert 'inifile: tox.ini\n' in result.stdout.str() -class TestProgress: +class TestProgress(object): @pytest.fixture def many_tests_files(self, testdir): @@ -1047,7 +1047,7 @@ class TestProgress: ]) -class TestProgressWithTeardown: +class TestProgressWithTeardown(object): """Ensure we show the correct percentages for tests that fail during teardown (#3088)""" @pytest.fixture