diff --git a/_pytest/_argcomplete.py b/_pytest/_argcomplete.py index 0625a75f9f1..ea8c98c7f5b 100644 --- a/_pytest/_argcomplete.py +++ b/_pytest/_argcomplete.py @@ -60,7 +60,7 @@ 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 a48e98c85aa..39c57c5f3c2 100644 --- a/_pytest/assertion/__init__.py +++ b/_pytest/assertion/__init__.py @@ -56,7 +56,7 @@ def mark_rewrite(self, *names): 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 c537c14472b..0db08a1aa6b 100755 --- a/_pytest/cacheprovider.py +++ b/_pytest/cacheprovider.py @@ -98,7 +98,7 @@ def set(self, key, value): 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 f2ebe38c8c0..36658acce6f 100644 --- a/_pytest/capture.py +++ b/_pytest/capture.py @@ -61,7 +61,7 @@ def silence_logging_at_shutdown(): 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 @@ def readouterr(self): 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 @@ def snap(self): 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 @@ def snap(self): 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 22bf6c60c1d..24887a5f321 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 @@ def __str__(self): 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 @@ def __repr__(self): 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 @@ def copy(self): return CmdOptions(self.__dict__) -class Notset: +class Notset(object): def __repr__(self): return "" diff --git a/_pytest/debugging.py b/_pytest/debugging.py index d7dca780956..23d94e6880d 100644 --- a/_pytest/debugging.py +++ b/_pytest/debugging.py @@ -40,7 +40,7 @@ def fin(): 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 @@ def set_trace(cls): 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 a2b6f7d9460..b899736e1b0 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 @@ def _get_active_fixturedef(self, argname): 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 teardown(): 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 fce4f35f383..1caa7ff1e7a 100644 --- a/_pytest/main.py +++ b/_pytest/main.py @@ -243,7 +243,7 @@ def find_module_patched(self, fullname, path=None): 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 6d095a592ff..45182bdcd33 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 40ae560f070..c402213e891 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 @@ def __repr__(self): 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 1ea85178554..c14a34d7e88 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 @@ def __repr__(self): 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 @@ def assert_outcomes(self, passed=0, skipped=0, failed=0, error=0): 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 @@ def restore(self): 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 @@ def restore(self): 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 @@ def restore(self): 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 @@ def revert_warn_already_imported(): rec = [] - class Collect: + class Collect(object): def pytest_configure(x, config): rec.append(self.make_hook_recorder(config.pluginmanager)) @@ -750,7 +750,7 @@ def pytest_configure(x, config): if len(rec) == 1: reprec = rec.pop() else: - class reprec: + class reprec(object): pass reprec.ret = ret @@ -780,13 +780,13 @@ def runpytest_inprocess(self, *args, **kwargs): 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 @@ def assert_contains_lines(self, lines2): 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 13abee36725..d82865b7684 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 f0a2fa6187e..51d21cb33f2 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 @@ def get_location(self, config): 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 da1b032237a..66b4a2d2fcc 100644 --- a/_pytest/tmpdir.py +++ b/_pytest/tmpdir.py @@ -8,7 +8,7 @@ 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 00000000000..8d2cfed5184 --- /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 729e93b7f07..49bd3a5cdc7 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 815fb54679e..437ec7d5e45 100644 --- a/testing/python/collect.py +++ b/testing/python/collect.py @@ -880,10 +880,10 @@ def test_issue2369_collect_module_fileext(self, testdir): 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 b159e8ebb8e..d22389e7110 100644 --- a/testing/python/fixture.py +++ b/testing/python/fixture.py @@ -2828,7 +2828,7 @@ def fixture1(): 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 0ed9f56bfee..06979681a03 100644 --- a/testing/python/metafunc.py +++ b/testing/python/metafunc.py @@ -241,7 +241,7 @@ def test_class_or_function_idval(self): """ 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 f769a725dc4..69afa0f9c84 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 dd39d31eaa6..87063371a8d 100644 --- a/testing/test_pytester.py +++ b/testing/test_pytester.py @@ -135,7 +135,7 @@ def setup_function(function): 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 @@ def test_inline_run_test_module_not_cleaned_up(self, testdir): 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_foo(): 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 @@ def test_preserve_container(self, monkeypatch): @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 7dfa4b01efd..574372da4ee 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 @@ def test_capture_no(self, many_tests_files, testdir): ]) -class TestProgressWithTeardown: +class TestProgressWithTeardown(object): """Ensure we show the correct percentages for tests that fail during teardown (#3088)""" @pytest.fixture