Skip to content

Commit 3a4d372

Browse files
authored
Merge pull request #2414 from nicoddemus/revert-new-style-classes
Revert refactor of old-style to new-style classes
2 parents 6f407ef + d86c89e commit 3a4d372

16 files changed

+45
-51
lines changed

CHANGELOG.rst

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,6 @@ Changes
3333
this is to prepare the removal of preloadconfig in pytest 4.0
3434
Thanks to `@RonnyPfannschmidt`_ for the PR.
3535

36-
* Old-style classes have been changed to new-style classes in order to improve
37-
compatibility with Python 2. Thanks to `@MichalTHEDUDE`_ and `@mandeep`_ for the PR (`#2147`_).
38-
3936
* It is now possible to skip test classes from being collected by setting a
4037
``__test__`` attribute to ``False`` in the class body (`#2007`_). Thanks
4138
to `@syre`_ for the report and `@lwm`_ for the PR.
@@ -123,7 +120,6 @@ Bug Fixes
123120
.. _#2013: https://github.com/pytest-dev/pytest/issues/2013
124121
.. _#2101: https://github.com/pytest-dev/pytest/pull/2101
125122
.. _#2166: https://github.com/pytest-dev/pytest/pull/2166
126-
.. _#2147: https://github.com/pytest-dev/pytest/issues/2147
127123
.. _#2208: https://github.com/pytest-dev/pytest/issues/2208
128124
.. _#2228: https://github.com/pytest-dev/pytest/issues/2228
129125
.. _#2308: https://github.com/pytest-dev/pytest/issues/2308

_pytest/_argcomplete.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
import os
6363
from glob import glob
6464

65-
class FastFilesCompleter(object):
65+
class FastFilesCompleter:
6666
'Fast file completer class'
6767
def __init__(self, directories=True):
6868
self.directories = directories

_pytest/assertion/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def mark_rewrite(self, *names):
5757
pass
5858

5959

60-
class AssertionState(object):
60+
class AssertionState:
6161
"""State for the assertion plugin."""
6262

6363
def __init__(self, config, mode):

_pytest/cacheprovider.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def set(self, key, value):
8787
json.dump(value, f, indent=2, sort_keys=True)
8888

8989

90-
class LFPlugin(object):
90+
class LFPlugin:
9191
""" Plugin which implements the --lf (run last-failing) option """
9292
def __init__(self, config):
9393
self.config = config

_pytest/capture.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def silence_logging_at_shutdown():
5757
sys.stderr.write(err)
5858

5959

60-
class CaptureManager(object):
60+
class CaptureManager:
6161
def __init__(self, method):
6262
self._method = method
6363

@@ -182,7 +182,7 @@ def capfd(request):
182182
return c
183183

184184

185-
class CaptureFixture(object):
185+
class CaptureFixture:
186186
def __init__(self, captureclass, request):
187187
self.captureclass = captureclass
188188
self.request = request
@@ -315,10 +315,10 @@ def readouterr(self):
315315
return (self.out.snap() if self.out is not None else "",
316316
self.err.snap() if self.err is not None else "")
317317

318-
class NoCapture(object):
318+
class NoCapture:
319319
__init__ = start = done = suspend = resume = lambda *args: None
320320

321-
class FDCapture(object):
321+
class FDCapture:
322322
""" Capture IO to/from a given os-level filedescriptor. """
323323

324324
def __init__(self, targetfd, tmpfile=None):
@@ -394,7 +394,7 @@ def writeorg(self, data):
394394
os.write(self.targetfd_save, data)
395395

396396

397-
class SysCapture(object):
397+
class SysCapture:
398398
def __init__(self, fd, tmpfile=None):
399399
name = patchsysdict[fd]
400400
self._old = getattr(sys, name)
@@ -432,7 +432,7 @@ def writeorg(self, data):
432432
self._old.flush()
433433

434434

435-
class DontReadFromInput(object):
435+
class DontReadFromInput:
436436
"""Temporary stub class. Ideally when stdin is accessed, the
437437
capturing should be turned off, with possibly all data captured
438438
so far sent to the screen. This should be configurable, though,

_pytest/config.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def main(args=None, plugins=None):
6363
sys.stderr.write("ERROR: %s\n" %(msg,))
6464
return 4
6565

66-
class cmdline(object): # compatibility namespace
66+
class cmdline: # compatibility namespace
6767
main = staticmethod(main)
6868

6969

@@ -464,7 +464,7 @@ def _get_plugin_specs_as_list(specs):
464464
return []
465465

466466

467-
class Parser(object):
467+
class Parser:
468468
""" Parser for command line arguments and ini-file values.
469469
470470
:ivar extra_info: dict of generic param -> value to display in case
@@ -599,7 +599,7 @@ def __str__(self):
599599
return self.msg
600600

601601

602-
class Argument(object):
602+
class Argument:
603603
"""class that mimics the necessary behaviour of optparse.Option
604604
605605
its currently a least effort implementation
@@ -729,7 +729,7 @@ def __repr__(self):
729729
return 'Argument({0})'.format(', '.join(args))
730730

731731

732-
class OptionGroup(object):
732+
class OptionGroup:
733733
def __init__(self, name, description="", parser=None):
734734
self.name = name
735735
self.description = description
@@ -855,7 +855,7 @@ def __repr__(self):
855855
def copy(self):
856856
return CmdOptions(self.__dict__)
857857

858-
class Notset(object):
858+
class Notset:
859859
def __repr__(self):
860860
return "<NOTSET>"
861861

_pytest/debugging.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,7 @@ def fin():
4040
pytestPDB._pdb_cls = pdb_cls
4141
config._cleanup.append(fin)
4242

43-
44-
class pytestPDB(object):
43+
class pytestPDB:
4544
""" Pseudo PDB that defers to the real pdb. """
4645
_pluginmanager = None
4746
_config = None
@@ -63,7 +62,7 @@ def set_trace(cls):
6362
cls._pdb_cls().set_trace(frame)
6463

6564

66-
class PdbInvoke(object):
65+
class PdbInvoke:
6766
def pytest_exception_interact(self, node, call, report):
6867
capman = node.config.pluginmanager.getplugin("capturemanager")
6968
if capman:

_pytest/fixtures.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ def fillfixtures(function):
241241
def get_direct_param_fixture_func(request):
242242
return request.param
243243

244-
class FuncFixtureInfo(object):
244+
class FuncFixtureInfo:
245245
def __init__(self, argnames, names_closure, name2fixturedefs):
246246
self.argnames = argnames
247247
self.names_closure = names_closure
@@ -439,7 +439,7 @@ def _get_active_fixturedef(self, argname):
439439
fixturedef = self._getnextfixturedef(argname)
440440
except FixtureLookupError:
441441
if argname == "request":
442-
class PseudoFixtureDef(object):
442+
class PseudoFixtureDef:
443443
cached_result = (self, [0], None)
444444
scope = "function"
445445
return PseudoFixtureDef
@@ -707,7 +707,7 @@ def teardown():
707707
return res
708708

709709

710-
class FixtureDef(object):
710+
class FixtureDef:
711711
""" A container for a factory definition. """
712712
def __init__(self, fixturemanager, baseid, argname, func, scope, params,
713713
unittest=False, ids=None):
@@ -806,7 +806,7 @@ def pytest_fixture_setup(fixturedef, request):
806806
return result
807807

808808

809-
class FixtureFunctionMarker(object):
809+
class FixtureFunctionMarker:
810810
def __init__(self, scope, params, autouse=False, ids=None, name=None):
811811
self.scope = scope
812812
self.params = params
@@ -893,7 +893,7 @@ def pytestconfig(request):
893893
return request.config
894894

895895

896-
class FixtureManager(object):
896+
class FixtureManager:
897897
"""
898898
pytest fixtures definitions and information is stored and managed
899899
from this class.

_pytest/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ def pytest_ignore_collect(path, config):
190190
return False
191191

192192

193-
class FSHookProxy(object):
193+
class FSHookProxy:
194194
def __init__(self, fspath, pm, remove_mods):
195195
self.fspath = fspath
196196
self.pm = pm

_pytest/mark.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ def pytest_collection_modifyitems(items, config):
152152
items[:] = remaining
153153

154154

155-
class MarkMapping(object):
155+
class MarkMapping:
156156
"""Provides a local mapping for markers where item access
157157
resolves to True if the marker is present. """
158158
def __init__(self, keywords):
@@ -166,7 +166,7 @@ def __getitem__(self, name):
166166
return name in self._mymarks
167167

168168

169-
class KeywordMapping(object):
169+
class KeywordMapping:
170170
"""Provides a local mapping for keywords.
171171
Given a list of names, map any substring of one of these names to True.
172172
"""
@@ -230,7 +230,7 @@ def pytest_unconfigure(config):
230230
MARK_GEN._config = getattr(config, '_old_mark_config', None)
231231

232232

233-
class MarkGenerator(object):
233+
class MarkGenerator:
234234
""" Factory for :class:`MarkDecorator` objects - exposed as
235235
a ``pytest.mark`` singleton instance. Example::
236236
@@ -270,8 +270,7 @@ def istestfunc(func):
270270
return hasattr(func, "__call__") and \
271271
getattr(func, "__name__", "<lambda>") != "<lambda>"
272272

273-
274-
class MarkDecorator(object):
273+
class MarkDecorator:
275274
""" A decorator for test functions and test classes. When applied
276275
it will create :class:`MarkInfo` objects which may be
277276
:ref:`retrieved by hooks as item keywords <excontrolskip>`.

_pytest/monkeypatch.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,15 +89,15 @@ def derive_importpath(import_path, raising):
8989
return attr, target
9090

9191

92-
class Notset(object):
92+
class Notset:
9393
def __repr__(self):
9494
return "<notset>"
9595

9696

9797
notset = Notset()
9898

9999

100-
class MonkeyPatch(object):
100+
class MonkeyPatch:
101101
""" Object returned by the ``monkeypatch`` fixture keeping a record of setattr/item/env/syspath changes.
102102
"""
103103

_pytest/pytester.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ def _pytest(request):
167167
"""
168168
return PytestArg(request)
169169

170-
class PytestArg(object):
170+
class PytestArg:
171171
def __init__(self, request):
172172
self.request = request
173173

@@ -182,7 +182,7 @@ def get_public_names(l):
182182
return [x for x in l if x[0] != "_"]
183183

184184

185-
class ParsedCall(object):
185+
class ParsedCall:
186186
def __init__(self, name, kwargs):
187187
self.__dict__.update(kwargs)
188188
self._name = name
@@ -193,7 +193,7 @@ def __repr__(self):
193193
return "<ParsedCall %r(**%r)>" %(self._name, d)
194194

195195

196-
class HookRecorder(object):
196+
class HookRecorder:
197197
"""Record all hooks called in a plugin manager.
198198
199199
This wraps all the hook calls in the plugin manager, recording
@@ -337,7 +337,7 @@ def testdir(request, tmpdir_factory):
337337

338338

339339
rex_outcome = re.compile(r"(\d+) ([\w-]+)")
340-
class RunResult(object):
340+
class RunResult:
341341
"""The result of running a command.
342342
343343
Attributes:
@@ -383,7 +383,7 @@ def assert_outcomes(self, passed=0, skipped=0, failed=0):
383383

384384

385385

386-
class Testdir(object):
386+
class Testdir:
387387
"""Temporary test directory with tools to test/run pytest itself.
388388
389389
This is based on the ``tmpdir`` fixture but provides a number of
@@ -711,7 +711,7 @@ def revert():
711711

712712
rec = []
713713

714-
class Collect(object):
714+
class Collect:
715715
def pytest_configure(x, config):
716716
rec.append(self.make_hook_recorder(config.pluginmanager))
717717

@@ -722,7 +722,7 @@ def pytest_configure(x, config):
722722
if len(rec) == 1:
723723
reprec = rec.pop()
724724
else:
725-
class reprec(object):
725+
class reprec:
726726
pass
727727
reprec.ret = ret
728728

@@ -747,13 +747,13 @@ def runpytest_inprocess(self, *args, **kwargs):
747747
reprec = self.inline_run(*args, **kwargs)
748748
except SystemExit as e:
749749

750-
class reprec(object):
750+
class reprec:
751751
ret = e.args[0]
752752

753753
except Exception:
754754
traceback.print_exc()
755755

756-
class reprec(object):
756+
class reprec:
757757
ret = 3
758758
finally:
759759
out, err = capture.readouterr()
@@ -1039,7 +1039,7 @@ def getdecoded(out):
10391039
py.io.saferepr(out),)
10401040

10411041

1042-
class LineComp(object):
1042+
class LineComp:
10431043
def __init__(self):
10441044
self.stringio = py.io.TextIO()
10451045

@@ -1055,7 +1055,7 @@ def assert_contains_lines(self, lines2):
10551055
return LineMatcher(lines1).fnmatch_lines(lines2)
10561056

10571057

1058-
class LineMatcher(object):
1058+
class LineMatcher:
10591059
"""Flexible matching of text.
10601060
10611061
This is a convenience class to test large texts like the output of

_pytest/runner.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def pytest_sessionstart(session):
4949
def pytest_sessionfinish(session):
5050
session._setupstate.teardown_all()
5151

52-
class NodeInfo(object):
52+
class NodeInfo:
5353
def __init__(self, location):
5454
self.location = location
5555

@@ -144,7 +144,7 @@ def call_runtest_hook(item, when, **kwds):
144144
ihook = getattr(item.ihook, hookname)
145145
return CallInfo(lambda: ihook(item=item, **kwds), when=when)
146146

147-
class CallInfo(object):
147+
class CallInfo:
148148
""" Result/Exception info a function invocation. """
149149
#: None or ExceptionInfo object.
150150
excinfo = None

_pytest/skipping.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def xfail(reason=""):
7272
xfail.Exception = XFailed
7373

7474

75-
class MarkEvaluator(object):
75+
class MarkEvaluator:
7676
def __init__(self, item, name):
7777
self.item = item
7878
self.name = name

0 commit comments

Comments
 (0)