diff --git a/_pytest/_argcomplete.py b/_pytest/_argcomplete.py index e86585591..cb93baa60 100644 --- a/_pytest/_argcomplete.py +++ b/_pytest/_argcomplete.py @@ -64,6 +64,7 @@ from glob import glob class FastFilesCompleter: 'Fast file completer class' + def __init__(self, directories=True): self.directories = directories diff --git a/_pytest/_code/code.py b/_pytest/_code/code.py index 92d7d5b0c..e921ceb3b 100644 --- a/_pytest/_code/code.py +++ b/_pytest/_code/code.py @@ -18,6 +18,7 @@ else: class Code(object): """ wrapper around Python code objects """ + def __init__(self, rawcode): if not hasattr(rawcode, "co_filename"): rawcode = getrawcode(rawcode) @@ -260,6 +261,7 @@ class Traceback(list): access to Traceback entries. """ Entry = TracebackEntry + def __init__(self, tb, excinfo=None): """ initialize from given python traceback object and ExceptionInfo """ self._excinfo = excinfo diff --git a/_pytest/_code/source.py b/_pytest/_code/source.py index 08b9c414d..bf83814fa 100644 --- a/_pytest/_code/source.py +++ b/_pytest/_code/source.py @@ -19,6 +19,7 @@ class Source(object): possibly deindenting it. """ _compilecounter = 0 + def __init__(self, *parts, **kwargs): self.lines = lines = [] de = kwargs.get('deindent', True) diff --git a/_pytest/cacheprovider.py b/_pytest/cacheprovider.py index 4573fd462..31cfb2a29 100755 --- a/_pytest/cacheprovider.py +++ b/_pytest/cacheprovider.py @@ -89,6 +89,7 @@ class Cache(object): class LFPlugin: """ Plugin which implements the --lf (run last-failing) option """ + def __init__(self, config): self.config = config active_keys = 'lf', 'failedfirst' diff --git a/_pytest/capture.py b/_pytest/capture.py index 56e03bba8..ea88e08f2 100644 --- a/_pytest/capture.py +++ b/_pytest/capture.py @@ -238,6 +238,7 @@ def safe_text_dupfile(f, mode, default_encoding="UTF8"): class EncodedFile(object): errors = "strict" # possibly needed by py3 code (issue555) + def __init__(self, buffer, encoding): self.buffer = buffer self.encoding = encoding diff --git a/_pytest/config.py b/_pytest/config.py index 7285d3d0a..2b8ba0b6c 100644 --- a/_pytest/config.py +++ b/_pytest/config.py @@ -176,6 +176,7 @@ class PytestPluginManager(PluginManager): ``pytest_plugins`` global variables found in plugins being loaded; * ``conftest.py`` loading during start-up; """ + def __init__(self): super(PytestPluginManager, self).__init__("pytest", implprefix="pytest_") self._conftest_plugins = set() @@ -805,6 +806,7 @@ class DropShorterLongHelpFormatter(argparse.HelpFormatter): - shortcut if there are only two options and one of them is a short one - cache result on action object as this is called at least 2 times """ + def _format_action_invocation(self, action): orgstr = argparse.HelpFormatter._format_action_invocation(self, action) if orgstr and orgstr[0] != '-': # only optional arguments @@ -854,10 +856,13 @@ def _ensure_removed_sysmodule(modname): class CmdOptions(object): """ holds cmdline options as attributes.""" + def __init__(self, values=()): self.__dict__.update(values) + def __repr__(self): return "" % (self.__dict__,) + def copy(self): return CmdOptions(self.__dict__) diff --git a/_pytest/fixtures.py b/_pytest/fixtures.py index 893043d89..9da418088 100644 --- a/_pytest/fixtures.py +++ b/_pytest/fixtures.py @@ -559,6 +559,7 @@ class FixtureRequest(FuncargnamesCompatAttr): class SubRequest(FixtureRequest): """ a sub request for handling getting a fixture from a test function/fixture. """ + def __init__(self, request, scope, param, param_index, fixturedef): self._parent_request = request self.fixturename = fixturedef.argname @@ -609,6 +610,7 @@ def scope2index(scope, descr, where=None): class FixtureLookupError(LookupError): """ could not return a requested Fixture (missing or invalid). """ + def __init__(self, argname, request, msg=None): self.argname = argname self.request = request @@ -709,6 +711,7 @@ def call_fixture_func(fixturefunc, request, kwargs): class FixtureDef: """ A container for a factory definition. """ + def __init__(self, fixturemanager, baseid, argname, func, scope, params, unittest=False, ids=None): self._fixturemanager = fixturemanager diff --git a/_pytest/mark.py b/_pytest/mark.py index ce48dd0f1..f9023ec2b 100644 --- a/_pytest/mark.py +++ b/_pytest/mark.py @@ -155,6 +155,7 @@ def pytest_collection_modifyitems(items, config): class MarkMapping: """Provides a local mapping for markers where item access resolves to True if the marker is present. """ + def __init__(self, keywords): mymarks = set() for key, value in keywords.items(): @@ -170,6 +171,7 @@ class KeywordMapping: """Provides a local mapping for keywords. Given a list of names, map any substring of one of these names to True. """ + def __init__(self, names): self._names = names @@ -303,6 +305,7 @@ class MarkDecorator: additional keyword or positional arguments. """ + def __init__(self, mark): assert isinstance(mark, Mark), repr(mark) self.mark = mark @@ -366,6 +369,7 @@ class Mark(namedtuple('Mark', 'name, args, kwargs')): class MarkInfo(object): """ Marking object created by :class:`MarkDecorator` instances. """ + def __init__(self, mark): assert isinstance(mark, Mark), repr(mark) self.combined = mark diff --git a/_pytest/pytester.py b/_pytest/pytester.py index 0ea4d6c44..ccad16e18 100644 --- a/_pytest/pytester.py +++ b/_pytest/pytester.py @@ -352,6 +352,7 @@ class RunResult: :duration: Duration in seconds. """ + def __init__(self, ret, outlines, errlines, duration): self.ret = ret self.outlines = outlines @@ -581,6 +582,7 @@ class Testdir: return p Session = Session + def getnode(self, config, arg): """Return the collection node of a file. diff --git a/_pytest/python.py b/_pytest/python.py index 9b6c5a39b..5b2224a6b 100644 --- a/_pytest/python.py +++ b/_pytest/python.py @@ -490,6 +490,7 @@ def _get_xunit_func(obj, name): class Class(PyCollector): """ Collector for test methods. """ + def collect(self): if not safe_getattr(self.obj, "__test__", True): return [] @@ -715,6 +716,7 @@ class Metafunc(fixtures.FuncargnamesCompatAttr): test configuration or values specified in the class or module where a test function is defined. """ + def __init__(self, function, fixtureinfo, config, cls=None, module=None): #: access to the :class:`_pytest.config.Config` object for the test session self.config = config @@ -1523,6 +1525,7 @@ class Function(FunctionMixin, main.Item, fixtures.FuncargnamesCompatAttr): Python test function. """ _genid = None + def __init__(self, name, parent, args=None, config=None, callspec=None, callobj=NOTSET, keywords=None, session=None, fixtureinfo=None, originalname=None): diff --git a/_pytest/runner.py b/_pytest/runner.py index 8c101557b..75e6db900 100644 --- a/_pytest/runner.py +++ b/_pytest/runner.py @@ -148,6 +148,7 @@ class CallInfo: """ Result/Exception info a function invocation. """ #: None or ExceptionInfo object. excinfo = None + def __init__(self, func, when): #: context of invocation: one of "setup", "call", #: "teardown", "memocollect" @@ -277,6 +278,7 @@ class TestReport(BaseReport): """ Basic test report object (also used for setup and teardown calls if they fail). """ + def __init__(self, nodeid, location, keywords, outcome, longrepr, when, sections=(), duration=0, **extra): #: normalized collection node id @@ -318,6 +320,7 @@ class TestReport(BaseReport): class TeardownErrorReport(BaseReport): outcome = "failed" when = "teardown" + def __init__(self, longrepr, **extra): self.longrepr = longrepr self.sections = [] @@ -370,11 +373,13 @@ class CollectReport(BaseReport): class CollectErrorRepr(TerminalRepr): def __init__(self, msg): self.longrepr = msg + def toterminal(self, out): out.line(self.longrepr, red=True) class SetupState(object): """ shared state for setting up/tearing down test items or collectors. """ + def __init__(self): self.stack = [] self._finalizers = {} @@ -469,6 +474,7 @@ class OutcomeException(Exception): """ OutcomeException and its subclass instances indicate and contain info about test and collection outcomes. """ + def __init__(self, msg=None, pytrace=True): Exception.__init__(self, msg) self.msg = msg @@ -500,6 +506,7 @@ class Failed(OutcomeException): class Exit(KeyboardInterrupt): """ raised for immediate program exits (no tracebacks/summaries)""" + def __init__(self, msg="unknown reason"): self.msg = msg KeyboardInterrupt.__init__(self, msg) diff --git a/_pytest/terminal.py b/_pytest/terminal.py index f0bf996f3..057abdccd 100644 --- a/_pytest/terminal.py +++ b/_pytest/terminal.py @@ -88,6 +88,7 @@ class WarningReport: """ Simple structure to hold warnings information captured by ``pytest_logwarning``. """ + def __init__(self, code, message, nodeid=None, fslocation=None): """ :param code: unused diff --git a/testing/acceptance_test.py b/testing/acceptance_test.py index ea8ef747e..4426c068e 100644 --- a/testing/acceptance_test.py +++ b/testing/acceptance_test.py @@ -764,6 +764,7 @@ class TestDurationWithFixture(object): def test_2(): time.sleep(frag) """ + def test_setup_function(self, testdir): testdir.makepyfile(self.source) result = testdir.runpytest("--durations=10") diff --git a/testing/code/test_excinfo.py b/testing/code/test_excinfo.py index b73ef5232..db0f263d3 100644 --- a/testing/code/test_excinfo.py +++ b/testing/code/test_excinfo.py @@ -33,14 +33,19 @@ class TWMock(object): def __init__(self): self.lines = [] self.is_writing = False + def sep(self, sep, line=None): self.lines.append((sep, line)) + def write(self, msg, **kw): self.lines.append((TWMock.WRITE, msg)) + def line(self, line, **kw): self.lines.append(line) + def markup(self, text, **kw): return text + def get_write_msg(self, idx): flag, msg = self.lines[idx] assert flag == TWMock.WRITE diff --git a/testing/code/test_source.py b/testing/code/test_source.py index a089db054..1f251f2a0 100644 --- a/testing/code/test_source.py +++ b/testing/code/test_source.py @@ -127,6 +127,7 @@ class TestAccesses(object): def g(x): pass """) + def test_getrange(self): x = self.source[0:2] assert x.isparseable() diff --git a/testing/python/metafunc.py b/testing/python/metafunc.py index c97dfcdcc..8c0bf41d0 100644 --- a/testing/python/metafunc.py +++ b/testing/python/metafunc.py @@ -1251,6 +1251,7 @@ class TestMetafuncFunctionalAuto(object): class TestMarkersWithParametrization(object): pytestmark = pytest.mark.issue308 + def test_simple_mark(self, testdir): s = """ import pytest diff --git a/testing/test_argcomplete.py b/testing/test_argcomplete.py index 0c11b1bc9..dad73d870 100644 --- a/testing/test_argcomplete.py +++ b/testing/test_argcomplete.py @@ -38,6 +38,7 @@ def _wrapcall(*args, **kargs): class FilesCompleter(object): 'File completer class, optionally takes a list of allowed extensions' + def __init__(self, allowednames=(), directories=True): # Fix if someone passes in a string instead of a list if type(allowednames) is str: diff --git a/testing/test_pytester.py b/testing/test_pytester.py index 932427ad3..9d0a3ef70 100644 --- a/testing/test_pytester.py +++ b/testing/test_pytester.py @@ -78,6 +78,7 @@ def make_holder(): class apiclass(object): def pytest_xyz(self, arg): "x" + def pytest_xyz_noarg(self): "x" diff --git a/testing/test_terminal.py b/testing/test_terminal.py index f9344ca30..a1e480a66 100644 --- a/testing/test_terminal.py +++ b/testing/test_terminal.py @@ -697,6 +697,7 @@ class TestGenericReporting(object): """ this test class can be subclassed with a different option provider to run e.g. distributed tests. """ + def test_collect_fail(self, testdir, option): testdir.makepyfile("import xyz\n") result = testdir.runpytest(*option.args) diff --git a/tox.ini b/tox.ini index d6c2938e8..e0cb0b80e 100644 --- a/tox.ini +++ b/tox.ini @@ -196,6 +196,6 @@ filterwarnings = ignore:.*inspect.getargspec.*deprecated, use inspect.signature.*:DeprecationWarning [flake8] -ignore = E301,E302,E303,E401,E402,E501,E701,E702,E704,E712,E731 +ignore = E302,E303,E401,E402,E501,E701,E702,E704,E712,E731 max-line-length = 120 exclude = _pytest/vendored_packages/pluggy.py