summaryrefslogtreecommitdiff
path: root/_pytest
diff options
context:
space:
mode:
authorholger krekel <holger@merlinux.eu>2013-10-12 15:39:22 +0200
committerholger krekel <holger@merlinux.eu>2013-10-12 15:39:22 +0200
commit8ac5af289666e023aa4189fb62d28d406b9e6bb6 (patch)
tree2c45d7891dc3ccf3db4847e3ab20c33def665acd /_pytest
parent8550ea0728ea8025daaf0fdfbf9ae1eb0cd3ad13 (diff)
downloadpytest-8ac5af289666e023aa4189fb62d28d406b9e6bb6.tar.gz
fix flakes issues and make --flakes run part of tox runs
Diffstat (limited to '_pytest')
-rw-r--r--_pytest/assertion/__init__.py10
-rw-r--r--_pytest/assertion/rewrite.py5
-rw-r--r--_pytest/config.py2
-rw-r--r--_pytest/helpconfig.py1
-rw-r--r--_pytest/main.py1
-rw-r--r--_pytest/pytester.py7
-rw-r--r--_pytest/python.py13
-rw-r--r--_pytest/skipping.py1
-rwxr-xr-x_pytest/standalonetemplate.py4
-rw-r--r--_pytest/terminal.py1
10 files changed, 16 insertions, 29 deletions
diff --git a/_pytest/assertion/__init__.py b/_pytest/assertion/__init__.py
index 72af6d4fe..5c64c908f 100644
--- a/_pytest/assertion/__init__.py
+++ b/_pytest/assertion/__init__.py
@@ -34,7 +34,7 @@ def pytest_configure(config):
mode = "plain"
if mode == "rewrite":
try:
- import ast
+ import ast # noqa
except ImportError:
mode = "reinterp"
else:
@@ -48,10 +48,10 @@ def pytest_configure(config):
m = monkeypatch()
config._cleanup.append(m.undo)
m.setattr(py.builtin.builtins, 'AssertionError',
- reinterpret.AssertionError)
+ reinterpret.AssertionError) # noqa
hook = None
if mode == "rewrite":
- hook = rewrite.AssertionRewritingHook()
+ hook = rewrite.AssertionRewritingHook() # noqa
sys.meta_path.insert(0, hook)
warn_about_missing_assertion(mode)
config._assertstate = AssertionState(config, mode)
@@ -101,9 +101,9 @@ def pytest_sessionfinish(session):
def _load_modules(mode):
"""Lazily import assertion related code."""
global rewrite, reinterpret
- from _pytest.assertion import reinterpret
+ from _pytest.assertion import reinterpret # noqa
if mode == "rewrite":
- from _pytest.assertion import rewrite
+ from _pytest.assertion import rewrite # noqa
def warn_about_missing_assertion(mode):
try:
diff --git a/_pytest/assertion/rewrite.py b/_pytest/assertion/rewrite.py
index a61ba9651..4a7a5aa9d 100644
--- a/_pytest/assertion/rewrite.py
+++ b/_pytest/assertion/rewrite.py
@@ -319,7 +319,7 @@ def rewrite_asserts(mod):
_saferepr = py.io.saferepr
-from _pytest.assertion.util import format_explanation as _format_explanation
+from _pytest.assertion.util import format_explanation as _format_explanation # noqa
def _should_repr_global_name(obj):
return not hasattr(obj, "__name__") and not py.builtin.callable(obj)
@@ -557,7 +557,8 @@ class AssertionRewriter(ast.NodeVisitor):
for i, v in enumerate(boolop.values):
if i:
fail_inner = []
- self.on_failure.append(ast.If(cond, fail_inner, []))
+ # cond is set in a prior loop iteration below
+ self.on_failure.append(ast.If(cond, fail_inner, [])) # noqa
self.on_failure = fail_inner
self.push_format_context()
res, expl = self.visit(v)
diff --git a/_pytest/config.py b/_pytest/config.py
index 36fb56425..43ae9f322 100644
--- a/_pytest/config.py
+++ b/_pytest/config.py
@@ -41,7 +41,7 @@ def get_plugin_manager():
return _preinit.pop(0)
# subsequent calls to main will create a fresh instance
pluginmanager = PytestPluginManager()
- pluginmanager.config = config = Config(pluginmanager) # XXX attr needed?
+ pluginmanager.config = Config(pluginmanager) # XXX attr needed?
for spec in default_plugins:
pluginmanager.import_plugin(spec)
return pluginmanager
diff --git a/_pytest/helpconfig.py b/_pytest/helpconfig.py
index 2be858f3b..0d96c4c58 100644
--- a/_pytest/helpconfig.py
+++ b/_pytest/helpconfig.py
@@ -120,7 +120,6 @@ def pytest_report_header(config):
if config.option.traceconfig:
lines.append("active plugins:")
- plugins = []
items = config.pluginmanager._name2plugin.items()
for name, plugin in items:
if hasattr(plugin, '__file__'):
diff --git a/_pytest/main.py b/_pytest/main.py
index 5d9c243ee..372a8019d 100644
--- a/_pytest/main.py
+++ b/_pytest/main.py
@@ -425,7 +425,6 @@ class Collector(Node):
def _prunetraceback(self, excinfo):
if hasattr(self, 'fspath'):
- path = self.fspath
traceback = excinfo.traceback
ntraceback = traceback.cut(path=self.fspath)
if ntraceback == traceback:
diff --git a/_pytest/pytester.py b/_pytest/pytester.py
index dbaae802d..8c1e73582 100644
--- a/_pytest/pytester.py
+++ b/_pytest/pytester.py
@@ -26,7 +26,6 @@ def pytest_addoption(parser):
def pytest_configure(config):
# This might be called multiple times. Only take the first.
global _pytest_fullpath
- import pytest
try:
_pytest_fullpath
except NameError:
@@ -121,7 +120,6 @@ class HookRecorder:
def contains(self, entries):
__tracebackhide__ = True
- from py.builtin import print_
i = 0
entries = list(entries)
backlocals = py.std.sys._getframe(1).f_locals
@@ -260,9 +258,6 @@ class TmpTestdir:
def makefile(self, ext, *args, **kwargs):
return self._makefile(ext, args, kwargs)
- def makeini(self, source):
- return self.makefile('cfg', setup=source)
-
def makeconftest(self, source):
return self.makepyfile(conftest=source)
@@ -475,7 +470,7 @@ class TmpTestdir:
# XXX we rely on script refering to the correct environment
# we cannot use "(py.std.sys.executable,script)"
# becaue on windows the script is e.g. a py.test.exe
- return (py.std.sys.executable, _pytest_fullpath,)
+ return (py.std.sys.executable, _pytest_fullpath,) # noqa
else:
py.test.skip("cannot run %r with --no-tools-on-path" % scriptname)
diff --git a/_pytest/python.py b/_pytest/python.py
index ee326f3ee..fc957acaa 100644
--- a/_pytest/python.py
+++ b/_pytest/python.py
@@ -4,7 +4,7 @@ import inspect
import sys
import pytest
from _pytest.main import getfslineno
-from _pytest.mark import MarkDecorator, MarkInfo
+from _pytest.mark import MarkDecorator
from _pytest.monkeypatch import monkeypatch
from py._code.code import TerminalRepr
@@ -177,7 +177,6 @@ def pytest_pyfunc_call(__multicall__, pyfuncitem):
def pytest_collect_file(path, parent):
ext = path.ext
- pb = path.purebasename
if ext == ".py":
if not parent.session.isinitpath(path):
for pat in parent.config.getini('python_files'):
@@ -914,10 +913,6 @@ def raises(ExpectedException, *args, **kwargs):
func(*args[1:], **kwargs)
except ExpectedException:
return py.code.ExceptionInfo()
- k = ", ".join(["%s=%r" % x for x in kwargs.items()])
- if k:
- k = ', ' + k
- expr = '%s(%r%s)' %(getattr(func, '__name__', func), args, k)
pytest.fail("DID NOT RAISE")
class RaisesContext(object):
@@ -1015,7 +1010,7 @@ class Function(FunctionMixin, pytest.Item, FuncargnamesCompatAttr):
def setup(self):
# check if parametrization happend with an empty list
try:
- empty = self.callspec._emptyparamspecified
+ self.callspec._emptyparamspecified
except AttributeError:
pass
else:
@@ -1392,10 +1387,10 @@ class FixtureLookupError(LookupError):
if msg is None:
fm = self.request._fixturemanager
- nodeid = self.request._parentid
available = []
for name, fixturedef in fm._arg2fixturedefs.items():
- faclist = list(fm._matchfactories(fixturedef, self.request._parentid))
+ faclist = list(fm._matchfactories(fixturedef,
+ self.request._parentid))
if faclist:
available.append(name)
msg = "fixture %r not found" % (self.argname,)
diff --git a/_pytest/skipping.py b/_pytest/skipping.py
index f6915d431..603611200 100644
--- a/_pytest/skipping.py
+++ b/_pytest/skipping.py
@@ -217,7 +217,6 @@ def pytest_terminal_summary(terminalreporter):
tr._tw.line(line)
def show_simple(terminalreporter, lines, stat, format):
- tw = terminalreporter._tw
failed = terminalreporter.stats.get(stat)
if failed:
for rep in failed:
diff --git a/_pytest/standalonetemplate.py b/_pytest/standalonetemplate.py
index da8039756..b67bf20f3 100755
--- a/_pytest/standalonetemplate.py
+++ b/_pytest/standalonetemplate.py
@@ -39,7 +39,7 @@ class DictImporter(object):
if is_pkg:
module.__path__ = [fullname]
- do_exec(co, module.__dict__)
+ do_exec(co, module.__dict__) # noqa
return sys.modules[fullname]
def get_source(self, name):
@@ -63,4 +63,4 @@ if __name__ == "__main__":
sys.meta_path.insert(0, importer)
entry = "@ENTRY@"
- do_exec(entry, locals())
+ do_exec(entry, locals()) # noqa
diff --git a/_pytest/terminal.py b/_pytest/terminal.py
index 55b5cd219..aa2e90428 100644
--- a/_pytest/terminal.py
+++ b/_pytest/terminal.py
@@ -5,7 +5,6 @@ This is a good source for looking at the various reporting hooks.
import pytest
import py
import sys
-import os
def pytest_addoption(parser):
group = parser.getgroup("terminal reporting", "reporting", after="general")