4 new commits in pytest: https://bitbucket.org/hpk42/pytest/commits/932e9cd5598d/ Changeset: 932e9cd5598d Branch: flake8-clean User: RonnyPfannschmidt Date: 2015-02-22 12:04:57+00:00 Summary: restructure and flake8 clean pytest.py Affected #: 1 file
diff -r 52f65c68c647c2addce892b9c93a45fbfb477e11 -r 932e9cd5598d54b00d252d9f3b7550b52c75aa09 pytest.py --- a/pytest.py +++ b/pytest.py @@ -2,17 +2,16 @@ """ pytest: unit and functional testing with Python. """ -__all__ = ['main'] - -if __name__ == '__main__': # if run as a script or by 'python -m pytest' - # we trigger the below "else" condition by the following import - import pytest - raise SystemExit(pytest.main()) - -# else we are imported from _pytest.config import main, UsageError, _preloadplugins, cmdline from _pytest import __version__ +import pytest -_preloadplugins() # to populate pytest.* namespace so help(pytest) works +__all__ = ['main', 'UsageError', 'cmdline', '__version__'] +if __name__ == '__main__': + # if run as a script or by 'python -m pytest' + raise SystemExit(pytest.main()) +else: + # we are imported, populate pytest.* namespace so help(pytest) works + _preloadplugins() https://bitbucket.org/hpk42/pytest/commits/dcd4cf8805c0/ Changeset: dcd4cf8805c0 Branch: flake8-clean User: RonnyPfannschmidt Date: 2015-02-22 12:10:15+00:00 Summary: flake8 clean setup.py Affected #: 1 file diff -r 932e9cd5598d54b00d252d9f3b7550b52c75aa09 -r dcd4cf8805c0650288d8db314b8f5ac3abb82054 setup.py --- a/setup.py +++ b/setup.py @@ -1,4 +1,5 @@ -import os, sys +import os +import sys from setuptools import setup, Command classifiers = ['Development Status :: 6 - Mature', @@ -10,8 +11,8 @@ 'Topic :: Software Development :: Testing', 'Topic :: Software Development :: Libraries', 'Topic :: Utilities'] + [ - ('Programming Language :: Python :: %s' % x) for x in - '2 2.6 2.7 3 3.2 3.3 3.4'.split()] + ('Programming Language :: Python :: %s' % x) + for x in '2 2.6 2.7 3 3.2 3.3 3.4'.split()] long_description = open('README.rst').read() @@ -31,7 +32,8 @@ url='http://pytest.org', license='MIT license', platforms=['unix', 'linux', 'osx', 'cygwin', 'win32'], - author='Holger Krekel, Benjamin Peterson, Ronny Pfannschmidt, Floris Bruynooghe and others', + author='Holger Krekel, Benjamin Peterson,' + ' Ronny Pfannschmidt, Floris Bruynooghe and others', author_email='holger at merlinux.eu', entry_points=make_entry_points(), classifiers=classifiers, @@ -51,8 +53,8 @@ else: if basename.startswith('pypy'): points = {'py.test-%s' % basename: target} - else: # cpython - points = {'py.test-%s.%s' % versioninfo[:2] : target} + else: # cpython + points = {'py.test-%s.%s' % versioninfo[:2]: target} points['py.test'] = target return points @@ -68,10 +70,13 @@ class PyTest(Command): user_options = [] + def initialize_options(self): pass + def finalize_options(self): pass + def run(self): import subprocess PPATH = [x for x in os.environ.get('PYTHONPATH', '').split(':') if x] https://bitbucket.org/hpk42/pytest/commits/6dc46b43b7cb/ Changeset: 6dc46b43b7cb Branch: flake8-clean User: RonnyPfannschmidt Date: 2015-02-22 12:20:47+00:00 Summary: flake8 clean core Affected #: 1 file diff -r dcd4cf8805c0650288d8db314b8f5ac3abb82054 -r 6dc46b43b7cb57dc77d6b33d6400f74518cacbda _pytest/core.py --- a/_pytest/core.py +++ b/_pytest/core.py @@ -7,10 +7,12 @@ import py # don't import pytest to avoid circular imports -assert py.__version__.split(".")[:2] >= ['1', '4'], ("installation problem: " +assert py.__version__.split(".")[:2] >= ['1', '4'], ( + "installation problem: " "%s is too old, remove or upgrade 'py'" % (py.__version__)) -py3 = sys.version_info > (3,0) +py3 = sys.version_info > (3, 0) + class TagTracer: def __init__(self): @@ -32,7 +34,7 @@ indent = " " * self.indent lines = [ - "%s%s [%s]\n" %(indent, content, ":".join(tags)) + "%s%s [%s]\n" % (indent, content, ":".join(tags)) ] for name, value in extra.items(): @@ -58,14 +60,18 @@ assert isinstance(tags, tuple) self._tag2proc[tags] = processor + class TagTracerSub: def __init__(self, root, tags): self.root = root self.tags = tags + def __call__(self, *args): self.root.processmessage(self.tags, args) + def setmyprocessor(self, processor): self.root.setprocessor(self.tags, processor) + def get(self, name): return self.__class__(self.root, self.tags + (name,)) @@ -82,6 +88,7 @@ """ name = wrapper_func.__name__ oldcall = getattr(cls, name) + def wrap_exec(*args, **kwargs): gen = wrapper_func(*args, **kwargs) return wrapped_call(gen, lambda: oldcall(*args, **kwargs)) @@ -89,10 +96,12 @@ setattr(cls, name, wrap_exec) return lambda: setattr(cls, name, oldcall) + def raise_wrapfail(wrap_controller, msg): co = wrap_controller.gi_code raise RuntimeError("wrap_controller at %r %s:%d %s" % - (co.co_name, co.co_filename, co.co_firstlineno, msg)) + (co.co_name, co.co_filename, co.co_firstlineno, msg)) + def wrapped_call(wrap_controller, func): """ Wrap calling to a function with a generator which needs to yield @@ -118,6 +127,7 @@ Calling the ``get_result`` method will return the result or reraise the exception raised when the function was called. """ excinfo = None + def __init__(self, func): try: self.result = func() @@ -181,9 +191,9 @@ return name = name or getattr(plugin, '__name__', str(id(plugin))) if self.isregistered(plugin, name): - raise ValueError("Plugin already registered: %s=%s\n%s" %( + raise ValueError("Plugin already registered: %s=%s\n%s" % ( name, plugin, self._name2plugin)) - #self.trace("registering", name, plugin) + # self.trace("registering", name, plugin) reg = getattr(self, "_registercallback", None) if reg is not None: reg(plugin, name) # may call addhooks @@ -267,7 +277,7 @@ try: from pkg_resources import iter_entry_points, DistributionNotFound except ImportError: - return # XXX issue a warning + return # XXX issue a warning for ep in iter_entry_points('pytest11'): name = ep.name if name.startswith("pytest_"): @@ -282,7 +292,7 @@ self.register(plugin, name=name) def consider_preparse(self, args): - for opt1,opt2 in zip(args, args[1:]): + for opt1, opt2 in zip(args, args[1:]): if opt1 == "-p": self.consider_pluginarg(opt2) @@ -325,9 +335,10 @@ except: e = sys.exc_info()[1] import pytest - if not hasattr(pytest, 'skip') or not isinstance(e, pytest.skip.Exception): + if not hasattr(pytest, 'skip') or \ + not isinstance(e, pytest.skip.Exception): raise - self._warnings.append("skipped plugin %r: %s" %((modname, e.msg))) + self._warnings.append("skipped plugin %r: %s" % ((modname, e.msg))) else: self.register(mod, modname) self.consider_module(mod) @@ -356,8 +367,9 @@ return l def call_plugin(self, plugin, methname, kwargs): - return MultiCall(methods=self.listattr(methname, plugins=[plugin]), - kwargs=kwargs, firstresult=True).execute() + return MultiCall( + methods=self.listattr(methname, plugins=[plugin]), + kwargs=kwargs, firstresult=True).execute() def importplugin(importspec): @@ -370,6 +382,7 @@ __import__(importspec) return sys.modules[importspec] + class MultiCall: """ execute a call into multiple python functions/methods. """ @@ -381,8 +394,9 @@ self.firstresult = firstresult def __repr__(self): - status = "%d results, %d meths" % (len(self.results), len(self.methods)) - return "<MultiCall %s, kwargs=%r>" %(status, self.kwargs) + status = "%d results, %d meths" % \ + (len(self.results), len(self.methods)) + return "<MultiCall %s, kwargs=%r>" % (status, self.kwargs) def execute(self): all_kwargs = self.kwargs @@ -400,7 +414,7 @@ return self.results -def varnames(func, startindex=None): +def varnames(func, startindex=None): # noqa - complexity 13 """ return argument name tuple for a function, method, class or callable. In case of a class, its "__init__" method is considered. @@ -460,9 +474,9 @@ argnames=varnames(method, startindex=isclass)) setattr(self, name, hc) added = True - #print ("setting new hook", name) + # print ("setting new hook", name) if not added: - raise ValueError("did not find new %r hooks in %r" %( + raise ValueError("did not find new %r hooks in %r" % ( prefix, hookspec,)) def _getcaller(self, name, plugins): @@ -475,7 +489,7 @@ def _scan_plugin(self, plugin): def fail(msg, *args): name = getattr(plugin, '__name__', plugin) - raise PluginValidationError("plugin %r\n%s" %(name, msg % args)) + raise PluginValidationError("plugin %r\n%s" % (name, msg % args)) for name in dir(plugin): if not name.startswith(self.prefix): @@ -493,7 +507,7 @@ "actual definition: %s\n" "available hookargs: %s", arg, formatdef(method), - ", ".join(hook.argnames)) + ", ".join(hook.argnames)) yield hook @@ -512,7 +526,7 @@ argnames=self.argnames, methods=methods) def __repr__(self): - return "<HookCaller %r>" %(self.name,) + return "<HookCaller %r>" % (self.name,) def scan_methods(self): self.methods = self.hookrelay._pm.listattr(self.name) @@ -531,13 +545,14 @@ class PluginValidationError(Exception): """ plugin failed validation. """ + def isgenerichook(name): return name == "pytest_plugins" or \ name.startswith("pytest_funcarg__") + def formatdef(func): return "%s%s" % ( func.__name__, inspect.formatargspec(*inspect.getargspec(func)) ) - https://bitbucket.org/hpk42/pytest/commits/605bc8fa35f9/ Changeset: 605bc8fa35f9 Branch: flake8-clean User: RonnyPfannschmidt Date: 2015-02-22 12:21:19+00:00 Summary: typo Affected #: 1 file diff -r 6dc46b43b7cb57dc77d6b33d6400f74518cacbda -r 605bc8fa35f9d9156aa5c404c3d750ddd3b9f8c2 tox.ini --- a/tox.ini +++ b/tox.ini @@ -15,7 +15,7 @@ [testenv:flake8] changedir= -deps = flake9 +deps = flake8 commands = flake8 {posargs:_pytest testing pytest.py setup.py} [testenv:py27-xdist] Repository URL: https://bitbucket.org/hpk42/pytest/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email. _______________________________________________ pytest-commit mailing list pytest-commit@python.org https://mail.python.org/mailman/listinfo/pytest-commit