Skip to content

Commit

Permalink
Refactored old style classes to new style classes
Browse files Browse the repository at this point in the history
  • Loading branch information
mandeep committed Jan 9, 2017
1 parent 3494dd0 commit d4afa15
Show file tree
Hide file tree
Showing 16 changed files with 49 additions and 49 deletions.
2 changes: 1 addition & 1 deletion _pytest/_argcomplete.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
import os
from glob import glob

class FastFilesCompleter:
class FastFilesCompleter(object):
'Fast file completer class'
def __init__(self, directories=True):
self.directories = directories
Expand Down
2 changes: 1 addition & 1 deletion _pytest/assertion/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def mark_rewrite(self, *names):
pass


class AssertionState:
class AssertionState(object):
"""State for the assertion plugin."""

def __init__(self, config, mode):
Expand Down
2 changes: 1 addition & 1 deletion _pytest/cacheprovider.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,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):
self.config = config
Expand Down
12 changes: 6 additions & 6 deletions _pytest/capture.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def silence_logging_at_shutdown():
sys.stderr.write(err)


class CaptureManager:
class CaptureManager(object):
def __init__(self, method):
self._method = method

Expand Down Expand Up @@ -182,7 +182,7 @@ def capfd(request):
return c


class CaptureFixture:
class CaptureFixture(object):
def __init__(self, captureclass, request):
self.captureclass = captureclass
self.request = request
Expand Down Expand Up @@ -315,10 +315,10 @@ def readouterr(self):
return (self.out.snap() if self.out is not None else "",
self.err.snap() if self.err is not None else "")

class NoCapture:
class NoCapture(object):
__init__ = start = done = suspend = resume = lambda *args: None

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

def __init__(self, targetfd, tmpfile=None):
Expand Down Expand Up @@ -394,7 +394,7 @@ def writeorg(self, data):
os.write(self.targetfd_save, data)


class SysCapture:
class SysCapture(object):
def __init__(self, fd, tmpfile=None):
name = patchsysdict[fd]
self._old = getattr(sys, name)
Expand Down Expand Up @@ -432,7 +432,7 @@ def writeorg(self, data):
self._old.flush()


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,
Expand Down
10 changes: 5 additions & 5 deletions _pytest/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def main(args=None, plugins=None):
sys.stderr.write("ERROR: %s\n" %(msg,))
return 4

class cmdline: # compatibility namespace
class cmdline(object): # compatibility namespace
main = staticmethod(main)


Expand Down Expand Up @@ -447,7 +447,7 @@ def import_plugin(self, modname):
self.consider_module(mod)


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
Expand Down Expand Up @@ -582,7 +582,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
Expand Down Expand Up @@ -712,7 +712,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
Expand Down Expand Up @@ -838,7 +838,7 @@ def __repr__(self):
def copy(self):
return CmdOptions(self.__dict__)

class Notset:
class Notset(object):
def __repr__(self):
return "<NOTSET>"

Expand Down
4 changes: 2 additions & 2 deletions _pytest/debugging.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def fin():
pytestPDB._pdb_cls = pdb_cls
config._cleanup.append(fin)

class pytestPDB:
class pytestPDB(object):
""" Pseudo PDB that defers to the real pdb. """
_pluginmanager = None
_config = None
Expand All @@ -64,7 +64,7 @@ def set_trace(self):
self._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:
Expand Down
12 changes: 6 additions & 6 deletions _pytest/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ def slice_items(items, ignore, scoped_argkeys_cache):



class FuncargnamesCompatAttr:
class FuncargnamesCompatAttr(object):
""" helper class so that Metafunc, Function and FixtureRequest
don't need to each define the "funcargnames" compatibility attribute.
"""
Expand Down Expand Up @@ -258,7 +258,7 @@ def fillfixtures(function):
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
Expand Down Expand Up @@ -456,7 +456,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
Expand Down Expand Up @@ -723,7 +723,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,
unittest=False, ids=None):
Expand Down Expand Up @@ -822,7 +822,7 @@ def pytest_fixture_setup(fixturedef, request):
return result


class FixtureFunctionMarker:
class FixtureFunctionMarker(object):
def __init__(self, scope, params, autouse=False, ids=None, name=None):
self.scope = scope
self.params = params
Expand Down Expand Up @@ -909,7 +909,7 @@ def pytestconfig(request):
return request.config


class FixtureManager:
class FixtureManager(object):
"""
pytest fixtures definitions and information is stored and managed
from this class.
Expand Down
2 changes: 1 addition & 1 deletion _pytest/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ def pytest_ignore_collect(path, config):
return False


class FSHookProxy:
class FSHookProxy(object):
def __init__(self, fspath, pm, remove_mods):
self.fspath = fspath
self.pm = pm
Expand Down
8 changes: 4 additions & 4 deletions _pytest/mark.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def pytest_collection_modifyitems(items, config):
items[:] = remaining


class MarkMapping:
class MarkMapping(object):
"""Provides a local mapping for markers where item access
resolves to True if the marker is present. """
def __init__(self, keywords):
Expand All @@ -113,7 +113,7 @@ def __getitem__(self, name):
return name in self._mymarks


class KeywordMapping:
class KeywordMapping(object):
"""Provides a local mapping for keywords.
Given a list of names, map any substring of one of these names to True.
"""
Expand Down Expand Up @@ -173,7 +173,7 @@ def pytest_configure(config):
pytest.mark._config = config


class MarkGenerator:
class MarkGenerator(object):
""" Factory for :class:`MarkDecorator` objects - exposed as
a ``pytest.mark`` singleton instance. Example::
Expand Down Expand Up @@ -210,7 +210,7 @@ def istestfunc(func):
return hasattr(func, "__call__") and \
getattr(func, "__name__", "<lambda>") != "<lambda>"

class MarkDecorator:
class MarkDecorator(object):
""" A decorator for test functions and test classes. When applied
it will create :class:`MarkInfo` objects which may be
:ref:`retrieved by hooks as item keywords <excontrolskip>`.
Expand Down
4 changes: 2 additions & 2 deletions _pytest/monkeypatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,15 @@ def derive_importpath(import_path, raising):
return attr, target


class Notset:
class Notset(object):
def __repr__(self):
return "<notset>"


notset = Notset()


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

Expand Down
22 changes: 11 additions & 11 deletions _pytest/pytester.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def _pytest(request):
"""
return PytestArg(request)

class PytestArg:
class PytestArg(object):
def __init__(self, request):
self.request = request

Expand All @@ -180,7 +180,7 @@ def get_public_names(l):
return [x for x in l if x[0] != "_"]


class ParsedCall:
class ParsedCall(object):
def __init__(self, name, kwargs):
self.__dict__.update(kwargs)
self._name = name
Expand All @@ -191,7 +191,7 @@ def __repr__(self):
return "<ParsedCall %r(**%r)>" %(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
Expand Down Expand Up @@ -335,7 +335,7 @@ def testdir(request, tmpdir_factory):


rex_outcome = re.compile("(\d+) ([\w-]+)")
class RunResult:
class RunResult(object):
"""The result of running a command.
Attributes:
Expand Down Expand Up @@ -380,7 +380,7 @@ def assert_outcomes(self, passed=0, skipped=0, failed=0):



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
Expand Down Expand Up @@ -707,7 +707,7 @@ def revert():

rec = []

class Collect:
class Collect(object):
def pytest_configure(x, config):
rec.append(self.make_hook_recorder(config.pluginmanager))

Expand All @@ -718,7 +718,7 @@ def pytest_configure(x, config):
if len(rec) == 1:
reprec = rec.pop()
else:
class reprec:
class reprec(object):
pass
reprec.ret = ret

Expand All @@ -742,13 +742,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.reset()
Expand Down Expand Up @@ -1033,7 +1033,7 @@ def getdecoded(out):
py.io.saferepr(out),)


class LineComp:
class LineComp(object):
def __init__(self):
self.stringio = py.io.TextIO()

Expand All @@ -1049,7 +1049,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
Expand Down
4 changes: 2 additions & 2 deletions _pytest/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def pytest_sessionstart(session):
def pytest_sessionfinish(session):
session._setupstate.teardown_all()

class NodeInfo:
class NodeInfo(object):
def __init__(self, location):
self.location = location

Expand Down Expand Up @@ -150,7 +150,7 @@ def call_runtest_hook(item, when, **kwds):
ihook = getattr(item.ihook, hookname)
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
Expand Down
2 changes: 1 addition & 1 deletion _pytest/skipping.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def xfail(reason=""):
xfail.Exception = XFailed


class MarkEvaluator:
class MarkEvaluator(object):
def __init__(self, item, name):
self.item = item
self.name = name
Expand Down
4 changes: 2 additions & 2 deletions _pytest/terminal.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,15 @@ def pytest_report_teststatus(report):
letter = "f"
return report.outcome, letter, report.outcome.upper()

class WarningReport:
class WarningReport(object):
def __init__(self, code, message, nodeid=None, fslocation=None):
self.code = code
self.message = message
self.nodeid = nodeid
self.fslocation = fslocation


class TerminalReporter:
class TerminalReporter(object):
def __init__(self, config, file=None):
import _pytest.config
self.config = config
Expand Down
Loading

0 comments on commit d4afa15

Please sign in to comment.