Merge remote-tracking branch 'upstream/master' into merge-master-into-features

This commit is contained in:
Bruno Oliveira 2017-11-10 18:33:02 -02:00
commit 983a09a2d4
43 changed files with 493 additions and 481 deletions

View File

@ -248,7 +248,7 @@ class TracebackEntry(object):
line = str(self.statement).lstrip() line = str(self.statement).lstrip()
except KeyboardInterrupt: except KeyboardInterrupt:
raise raise
except: except: # noqa
line = "???" line = "???"
return " File %r:%d in %s\n %s\n" % (fn, self.lineno + 1, name, line) return " File %r:%d in %s\n %s\n" % (fn, self.lineno + 1, name, line)
@ -336,16 +336,16 @@ class Traceback(list):
# XXX needs a test # XXX needs a test
key = entry.frame.code.path, id(entry.frame.code.raw), entry.lineno key = entry.frame.code.path, id(entry.frame.code.raw), entry.lineno
# print "checking for recursion at", key # print "checking for recursion at", key
l = cache.setdefault(key, []) values = cache.setdefault(key, [])
if l: if values:
f = entry.frame f = entry.frame
loc = f.f_locals loc = f.f_locals
for otherloc in l: for otherloc in values:
if f.is_true(f.eval(co_equal, if f.is_true(f.eval(co_equal,
__recursioncache_locals_1=loc, __recursioncache_locals_1=loc,
__recursioncache_locals_2=otherloc)): __recursioncache_locals_2=otherloc)):
return i return i
l.append(entry.frame.f_locals) values.append(entry.frame.f_locals)
return None return None
@ -476,12 +476,12 @@ class FormattedExcinfo(object):
s = str(source.getstatement(len(source) - 1)) s = str(source.getstatement(len(source) - 1))
except KeyboardInterrupt: except KeyboardInterrupt:
raise raise
except: except: # noqa
try: try:
s = str(source[-1]) s = str(source[-1])
except KeyboardInterrupt: except KeyboardInterrupt:
raise raise
except: except: # noqa
return 0 return 0
return 4 + (len(s) - len(s.lstrip())) return 4 + (len(s) - len(s.lstrip()))

View File

@ -255,7 +255,7 @@ def findsource(obj):
sourcelines, lineno = py.std.inspect.findsource(obj) sourcelines, lineno = py.std.inspect.findsource(obj)
except py.builtin._sysex: except py.builtin._sysex:
raise raise
except: except: # noqa
return None, -1 return None, -1
source = Source() source = Source()
source.lines = [line.rstrip() for line in sourcelines] source.lines = [line.rstrip() for line in sourcelines]
@ -320,22 +320,22 @@ def get_statement_startend2(lineno, node):
import ast import ast
# flatten all statements and except handlers into one lineno-list # flatten all statements and except handlers into one lineno-list
# AST's line numbers start indexing at 1 # AST's line numbers start indexing at 1
l = [] values = []
for x in ast.walk(node): for x in ast.walk(node):
if isinstance(x, _ast.stmt) or isinstance(x, _ast.ExceptHandler): if isinstance(x, _ast.stmt) or isinstance(x, _ast.ExceptHandler):
l.append(x.lineno - 1) values.append(x.lineno - 1)
for name in "finalbody", "orelse": for name in "finalbody", "orelse":
val = getattr(x, name, None) val = getattr(x, name, None)
if val: if val:
# treat the finally/orelse part as its own statement # treat the finally/orelse part as its own statement
l.append(val[0].lineno - 1 - 1) values.append(val[0].lineno - 1 - 1)
l.sort() values.sort()
insert_index = bisect_right(l, lineno) insert_index = bisect_right(values, lineno)
start = l[insert_index - 1] start = values[insert_index - 1]
if insert_index >= len(l): if insert_index >= len(values):
end = None end = None
else: else:
end = l[insert_index] end = values[insert_index]
return start, end return start, end

View File

@ -210,7 +210,7 @@ class AssertionRewritingHook(object):
mod.__cached__ = pyc mod.__cached__ = pyc
mod.__loader__ = self mod.__loader__ = self
py.builtin.exec_(co, mod.__dict__) py.builtin.exec_(co, mod.__dict__)
except: except: # noqa
if name in sys.modules: if name in sys.modules:
del sys.modules[name] del sys.modules[name]
raise raise

View File

@ -54,11 +54,11 @@ def _split_explanation(explanation):
""" """
raw_lines = (explanation or u('')).split('\n') raw_lines = (explanation or u('')).split('\n')
lines = [raw_lines[0]] lines = [raw_lines[0]]
for l in raw_lines[1:]: for values in raw_lines[1:]:
if l and l[0] in ['{', '}', '~', '>']: if values and values[0] in ['{', '}', '~', '>']:
lines.append(l) lines.append(values)
else: else:
lines[-1] += '\\n' + l lines[-1] += '\\n' + values
return lines return lines

View File

@ -1152,10 +1152,10 @@ class Config(object):
return [] return []
if type == "pathlist": if type == "pathlist":
dp = py.path.local(self.inicfg.config.path).dirpath() dp = py.path.local(self.inicfg.config.path).dirpath()
l = [] values = []
for relpath in shlex.split(value): for relpath in shlex.split(value):
l.append(dp.join(relpath, abs=True)) values.append(dp.join(relpath, abs=True))
return l return values
elif type == "args": elif type == "args":
return shlex.split(value) return shlex.split(value)
elif type == "linelist": elif type == "linelist":
@ -1172,13 +1172,13 @@ class Config(object):
except KeyError: except KeyError:
return None return None
modpath = py.path.local(mod.__file__).dirpath() modpath = py.path.local(mod.__file__).dirpath()
l = [] values = []
for relroot in relroots: for relroot in relroots:
if not isinstance(relroot, py.path.local): if not isinstance(relroot, py.path.local):
relroot = relroot.replace("/", py.path.local.sep) relroot = relroot.replace("/", py.path.local.sep)
relroot = modpath.join(relroot, abs=True) relroot = modpath.join(relroot, abs=True)
l.append(relroot) values.append(relroot)
return l return values
def _get_override_ini_value(self, name): def _get_override_ini_value(self, name):
value = None value = None

View File

@ -458,13 +458,13 @@ class FixtureRequest(FuncargnamesCompatAttr):
def _get_fixturestack(self): def _get_fixturestack(self):
current = self current = self
l = [] values = []
while 1: while 1:
fixturedef = getattr(current, "_fixturedef", None) fixturedef = getattr(current, "_fixturedef", None)
if fixturedef is None: if fixturedef is None:
l.reverse() values.reverse()
return l return values
l.append(fixturedef) values.append(fixturedef)
current = current._parent_request current = current._parent_request
def _getfixturevalue(self, fixturedef): def _getfixturevalue(self, fixturedef):
@ -746,7 +746,7 @@ class FixtureDef:
try: try:
func = self._finalizer.pop() func = self._finalizer.pop()
func() func()
except: except: # noqa
exceptions.append(sys.exc_info()) exceptions.append(sys.exc_info())
if exceptions: if exceptions:
e = exceptions[0] e = exceptions[0]

View File

@ -112,7 +112,7 @@ def wrap_session(config, doit):
excinfo.typename, excinfo.value.msg)) excinfo.typename, excinfo.value.msg))
config.hook.pytest_keyboard_interrupt(excinfo=excinfo) config.hook.pytest_keyboard_interrupt(excinfo=excinfo)
session.exitstatus = EXIT_INTERRUPTED session.exitstatus = EXIT_INTERRUPTED
except: except: # noqa
excinfo = _pytest._code.ExceptionInfo() excinfo = _pytest._code.ExceptionInfo()
config.notify_exception(excinfo, config.option) config.notify_exception(excinfo, config.option)
session.exitstatus = EXIT_INTERNALERROR session.exitstatus = EXIT_INTERNALERROR

View File

@ -296,12 +296,12 @@ class MarkGenerator:
return return
except AttributeError: except AttributeError:
pass pass
self._markers = l = set() self._markers = values = set()
for line in self._config.getini("markers"): for line in self._config.getini("markers"):
marker, _ = line.split(":", 1) marker, _ = line.split(":", 1)
marker = marker.rstrip() marker = marker.rstrip()
x = marker.split("(", 1)[0] x = marker.split("(", 1)[0]
l.add(x) values.add(x)
if name not in self._markers: if name not in self._markers:
raise AttributeError("%r not a registered marker" % (name,)) raise AttributeError("%r not a registered marker" % (name,))

View File

@ -174,9 +174,9 @@ class PytestArg:
return hookrecorder return hookrecorder
def get_public_names(l): def get_public_names(values):
"""Only return names from iterator l without a leading underscore.""" """Only return names from iterator values without a leading underscore."""
return [x for x in l if x[0] != "_"] return [x for x in values if x[0] != "_"]
class ParsedCall: class ParsedCall:
@ -250,9 +250,9 @@ class HookRecorder:
pytest.fail("\n".join(lines)) pytest.fail("\n".join(lines))
def getcall(self, name): def getcall(self, name):
l = self.getcalls(name) values = self.getcalls(name)
assert len(l) == 1, (name, l) assert len(values) == 1, (name, values)
return l[0] return values[0]
# functionality for test reports # functionality for test reports
@ -263,7 +263,7 @@ class HookRecorder:
def matchreport(self, inamepart="", def matchreport(self, inamepart="",
names="pytest_runtest_logreport pytest_collectreport", when=None): names="pytest_runtest_logreport pytest_collectreport", when=None):
""" return a testreport whose dotted import path matches """ """ return a testreport whose dotted import path matches """
l = [] values = []
for rep in self.getreports(names=names): for rep in self.getreports(names=names):
try: try:
if not when and rep.when != "call" and rep.passed: if not when and rep.when != "call" and rep.passed:
@ -274,14 +274,14 @@ class HookRecorder:
if when and getattr(rep, 'when', None) != when: if when and getattr(rep, 'when', None) != when:
continue continue
if not inamepart or inamepart in rep.nodeid.split("::"): if not inamepart or inamepart in rep.nodeid.split("::"):
l.append(rep) values.append(rep)
if not l: if not values:
raise ValueError("could not find test report matching %r: " raise ValueError("could not find test report matching %r: "
"no test reports at all!" % (inamepart,)) "no test reports at all!" % (inamepart,))
if len(l) > 1: if len(values) > 1:
raise ValueError( raise ValueError(
"found 2 or more testreports matching %r: %s" % (inamepart, l)) "found 2 or more testreports matching %r: %s" % (inamepart, values))
return l[0] return values[0]
def getfailures(self, def getfailures(self,
names='pytest_runtest_logreport pytest_collectreport'): names='pytest_runtest_logreport pytest_collectreport'):
@ -652,8 +652,8 @@ class Testdir:
""" """
p = self.makepyfile(source) p = self.makepyfile(source)
l = list(cmdlineargs) + [p] values = list(cmdlineargs) + [p]
return self.inline_run(*l) return self.inline_run(*values)
def inline_genitems(self, *args): def inline_genitems(self, *args):
"""Run ``pytest.main(['--collectonly'])`` in-process. """Run ``pytest.main(['--collectonly'])`` in-process.

View File

@ -325,7 +325,7 @@ class PyCollector(PyobjMixin, main.Collector):
for basecls in inspect.getmro(self.obj.__class__): for basecls in inspect.getmro(self.obj.__class__):
dicts.append(basecls.__dict__) dicts.append(basecls.__dict__)
seen = {} seen = {}
l = [] values = []
for dic in dicts: for dic in dicts:
for name, obj in list(dic.items()): for name, obj in list(dic.items()):
if name in seen: if name in seen:
@ -336,9 +336,9 @@ class PyCollector(PyobjMixin, main.Collector):
continue continue
if not isinstance(res, list): if not isinstance(res, list):
res = [res] res = [res]
l.extend(res) values.extend(res)
l.sort(key=lambda item: item.reportinfo()[:2]) values.sort(key=lambda item: item.reportinfo()[:2])
return l return values
def makeitem(self, name, obj): def makeitem(self, name, obj):
warnings.warn(deprecated.COLLECTOR_MAKEITEM, stacklevel=2) warnings.warn(deprecated.COLLECTOR_MAKEITEM, stacklevel=2)
@ -600,7 +600,7 @@ class Generator(FunctionMixin, PyCollector):
self.session._setupstate.prepare(self) self.session._setupstate.prepare(self)
# see FunctionMixin.setup and test_setupstate_is_preserved_134 # see FunctionMixin.setup and test_setupstate_is_preserved_134
self._preservedparent = self.parent.obj self._preservedparent = self.parent.obj
l = [] values = []
seen = {} seen = {}
for i, x in enumerate(self.obj()): for i, x in enumerate(self.obj()):
name, call, args = self.getcallargs(x) name, call, args = self.getcallargs(x)
@ -613,9 +613,9 @@ class Generator(FunctionMixin, PyCollector):
if name in seen: if name in seen:
raise ValueError("%r generated tests with non-unique name %r" % (self, name)) raise ValueError("%r generated tests with non-unique name %r" % (self, name))
seen[name] = True seen[name] = True
l.append(self.Function(name, self, args=args, callobj=call)) values.append(self.Function(name, self, args=args, callobj=call))
self.warn('C1', deprecated.YIELD_TESTS) self.warn('C1', deprecated.YIELD_TESTS)
return l return values
def getcallargs(self, obj): def getcallargs(self, obj):
if not isinstance(obj, (tuple, list)): if not isinstance(obj, (tuple, list)):

View File

@ -85,7 +85,7 @@ class ApproxNumpy(ApproxBase):
try: try:
actual = np.asarray(actual) actual = np.asarray(actual)
except: except: # noqa
raise TypeError("cannot compare '{0}' to numpy.ndarray".format(actual)) raise TypeError("cannot compare '{0}' to numpy.ndarray".format(actual))
if actual.shape != self.expected.shape: if actual.shape != self.expected.shape:

View File

@ -197,7 +197,7 @@ class CallInfo:
except KeyboardInterrupt: except KeyboardInterrupt:
self.stop = time() self.stop = time()
raise raise
except: except: # noqa
self.excinfo = ExceptionInfo() self.excinfo = ExceptionInfo()
self.stop = time() self.stop = time()

View File

@ -366,10 +366,10 @@ def folded_skips(skipped):
if when == 'setup' and 'skip' in keywords and 'pytestmark' not in keywords: if when == 'setup' and 'skip' in keywords and 'pytestmark' not in keywords:
key = (key[0], None, key[2], ) key = (key[0], None, key[2], )
d.setdefault(key, []).append(event) d.setdefault(key, []).append(event)
l = [] values = []
for key, events in d.items(): for key, events in d.items():
l.append((len(events),) + key) values.append((len(events),) + key)
return l return values
def show_skipped(terminalreporter, lines): def show_skipped(terminalreporter, lines):

View File

@ -459,9 +459,9 @@ class TerminalReporter:
line = self.config.cwd_relative_nodeid(nodeid) line = self.config.cwd_relative_nodeid(nodeid)
if domain and line.endswith(domain): if domain and line.endswith(domain):
line = line[:-len(domain)] line = line[:-len(domain)]
l = domain.split("[") values = domain.split("[")
l[0] = l[0].replace('.', '::') # don't replace '.' in params values[0] = values[0].replace('.', '::') # don't replace '.' in params
line += "[".join(l) line += "[".join(values)
return line return line
# collect_fspath comes from testid which has a "/"-normalized path # collect_fspath comes from testid which has a "/"-normalized path
@ -493,11 +493,11 @@ class TerminalReporter:
# summaries for sessionfinish # summaries for sessionfinish
# #
def getreports(self, name): def getreports(self, name):
l = [] values = []
for x in self.stats.get(name, []): for x in self.stats.get(name, []):
if not hasattr(x, '_pdbshown'): if not hasattr(x, '_pdbshown'):
l.append(x) values.append(x)
return l return values
def summary_warnings(self): def summary_warnings(self):
if self.hasopt("w"): if self.hasopt("w"):
@ -608,8 +608,8 @@ def repr_pythonversion(v=None):
return str(v) return str(v)
def flatten(l): def flatten(values):
for x in l: for x in values:
if isinstance(x, (list, tuple)): if isinstance(x, (list, tuple)):
for y in flatten(x): for y in flatten(x):
yield y yield y
@ -650,7 +650,7 @@ def build_summary_stats_line(stats):
def _plugin_nameversions(plugininfo): def _plugin_nameversions(plugininfo):
l = [] values = []
for plugin, dist in plugininfo: for plugin, dist in plugininfo:
# gets us name and version! # gets us name and version!
name = '{dist.project_name}-{dist.version}'.format(dist=dist) name = '{dist.project_name}-{dist.version}'.format(dist=dist)
@ -659,6 +659,6 @@ def _plugin_nameversions(plugininfo):
name = name[7:] name = name[7:]
# we decided to print python package names # we decided to print python package names
# they can have more than one plugin # they can have more than one plugin
if name not in l: if name not in values:
l.append(name) values.append(name)
return l return values

View File

@ -108,13 +108,13 @@ class TestCaseFunction(Function):
except TypeError: except TypeError:
try: try:
try: try:
l = traceback.format_exception(*rawexcinfo) values = traceback.format_exception(*rawexcinfo)
l.insert(0, "NOTE: Incompatible Exception Representation, " values.insert(0, "NOTE: Incompatible Exception Representation, "
"displaying natively:\n\n") "displaying natively:\n\n")
fail("".join(l), pytrace=False) fail("".join(values), pytrace=False)
except (fail.Exception, KeyboardInterrupt): except (fail.Exception, KeyboardInterrupt):
raise raise
except: except: # noqa
fail("ERROR: Unknown Incompatible Exception " fail("ERROR: Unknown Incompatible Exception "
"representation:\n%r" % (rawexcinfo,), pytrace=False) "representation:\n%r" % (rawexcinfo,), pytrace=False)
except KeyboardInterrupt: except KeyboardInterrupt:

1
changelog/2893.doc Normal file
View File

@ -0,0 +1 @@
Clarify language of proposal for fixtures parameters

1
changelog/2903.doc Normal file
View File

@ -0,0 +1 @@
List python 3.6 in the documented supported versions in the getting started document.

View File

@ -201,6 +201,9 @@ list::
Note that when calling ``metafunc.parametrize`` multiple times with different parameter sets, all parameter names across Note that when calling ``metafunc.parametrize`` multiple times with different parameter sets, all parameter names across
those sets cannot be duplicated, otherwise an error will be raised. those sets cannot be duplicated, otherwise an error will be raised.
More examples
-------------
For further examples, you might want to look at :ref:`more For further examples, you might want to look at :ref:`more
parametrization examples <paramexamples>`. parametrization examples <paramexamples>`.

View File

@ -1,8 +1,13 @@
:orphan: :orphan:
========================= ===================================
Parametrize with fixtures PROPOSAL: Parametrize with fixtures
========================= ===================================
.. warning::
This document outlines a proposal around using fixtures as input
of parametrized tests or fixtures.
Problem Problem
------- -------
@ -108,8 +113,13 @@ the following values.
Alternative approach Alternative approach
-------------------- --------------------
A new helper function named ``fixture_request`` tells pytest to yield all A new helper function named ``fixture_request`` would tell pytest to yield
parameters of a fixture. all parameters marked as a fixture.
.. note::
The `pytest-lazy-fixture <https://pypi.python.org/pypi/pytest-lazy-fixture>`_ plugin implements a very
similar solution to the proposal below, make sure to check it out.
.. code-block:: python .. code-block:: python

View File

@ -76,8 +76,8 @@ def test_excinfo_getstatement():
linenumbers = [_pytest._code.getrawcode(f).co_firstlineno - 1 + 4, linenumbers = [_pytest._code.getrawcode(f).co_firstlineno - 1 + 4,
_pytest._code.getrawcode(f).co_firstlineno - 1 + 1, _pytest._code.getrawcode(f).co_firstlineno - 1 + 1,
_pytest._code.getrawcode(g).co_firstlineno - 1 + 1, ] _pytest._code.getrawcode(g).co_firstlineno - 1 + 1, ]
l = list(excinfo.traceback) values = list(excinfo.traceback)
foundlinenumbers = [x.lineno for x in l] foundlinenumbers = [x.lineno for x in values]
assert foundlinenumbers == linenumbers assert foundlinenumbers == linenumbers
# for x in info: # for x in info:
# print "%s:%d %s" %(x.path.relto(root), x.lineno, x.statement) # print "%s:%d %s" %(x.path.relto(root), x.lineno, x.statement)
@ -243,7 +243,7 @@ class TestTraceback_f_g_h(object):
def f(n): def f(n):
try: try:
do_stuff() do_stuff()
except: except: # noqa
reraise_me() reraise_me()
excinfo = pytest.raises(RuntimeError, f, 8) excinfo = pytest.raises(RuntimeError, f, 8)
@ -430,7 +430,7 @@ class TestFormattedExcinfo(object):
exec(source.compile()) exec(source.compile())
except KeyboardInterrupt: except KeyboardInterrupt:
raise raise
except: except: # noqa
return _pytest._code.ExceptionInfo() return _pytest._code.ExceptionInfo()
assert 0, "did not raise" assert 0, "did not raise"
@ -1213,7 +1213,7 @@ def test_exception_repr_extraction_error_on_recursion():
try: try:
a(numpy_like()) a(numpy_like())
except: except: # noqa
from _pytest._code.code import ExceptionInfo from _pytest._code.code import ExceptionInfo
from _pytest.pytester import LineMatcher from _pytest.pytester import LineMatcher
exc_info = ExceptionInfo() exc_info = ExceptionInfo()
@ -1237,7 +1237,7 @@ def test_no_recursion_index_on_recursion_error():
return getattr(self, '_' + attr) return getattr(self, '_' + attr)
RecursionDepthError().trigger RecursionDepthError().trigger
except: except: # noqa
from _pytest._code.code import ExceptionInfo from _pytest._code.code import ExceptionInfo
exc_info = ExceptionInfo() exc_info = ExceptionInfo()
assert 'maximum recursion' in str(exc_info.getrepr()) assert 'maximum recursion' in str(exc_info.getrepr())

View File

@ -155,8 +155,8 @@ class TestAccesses(object):
assert len(self.source) == 4 assert len(self.source) == 4
def test_iter(self): def test_iter(self):
l = [x for x in self.source] values = [x for x in self.source]
assert len(l) == 4 assert len(values) == 4
class TestSourceParsingAndCompiling(object): class TestSourceParsingAndCompiling(object):
@ -329,8 +329,8 @@ def test_getstartingblock_singleline():
x = A('x', 'y') x = A('x', 'y')
l = [i for i in x.source.lines if i.strip()] values = [i for i in x.source.lines if i.strip()]
assert len(l) == 1 assert len(values) == 1
def test_getline_finally(): def test_getline_finally():

View File

@ -22,5 +22,5 @@ def test_getstartingblock_multiline():
, ,
'z') 'z')
l = [i for i in x.source.lines if i.strip()] values = [i for i in x.source.lines if i.strip()]
assert len(l) == 4 assert len(values) == 4

View File

@ -868,11 +868,11 @@ class TestConftestCustomization(object):
def test_makeitem_non_underscore(self, testdir, monkeypatch): def test_makeitem_non_underscore(self, testdir, monkeypatch):
modcol = testdir.getmodulecol("def _hello(): pass") modcol = testdir.getmodulecol("def _hello(): pass")
l = [] values = []
monkeypatch.setattr(pytest.Module, 'makeitem', monkeypatch.setattr(pytest.Module, 'makeitem',
lambda self, name, obj: l.append(name)) lambda self, name, obj: values.append(name))
l = modcol.collect() values = modcol.collect()
assert '_hello' not in l assert '_hello' not in values
def test_issue2369_collect_module_fileext(self, testdir): def test_issue2369_collect_module_fileext(self, testdir):
"""Ensure we can collect files with weird file extensions as Python """Ensure we can collect files with weird file extensions as Python

View File

@ -544,12 +544,12 @@ class TestRequestBasic(object):
def test_getfixturevalue(self, testdir, getfixmethod): def test_getfixturevalue(self, testdir, getfixmethod):
item = testdir.getitem(""" item = testdir.getitem("""
import pytest import pytest
l = [2] values = [2]
@pytest.fixture @pytest.fixture
def something(request): return 1 def something(request): return 1
@pytest.fixture @pytest.fixture
def other(request): def other(request):
return l.pop() return values.pop()
def test_func(something): pass def test_func(something): pass
""") """)
import contextlib import contextlib
@ -618,15 +618,15 @@ class TestRequestBasic(object):
def test_request_addfinalizer_failing_setup(self, testdir): def test_request_addfinalizer_failing_setup(self, testdir):
testdir.makepyfile(""" testdir.makepyfile("""
import pytest import pytest
l = [1] values = [1]
@pytest.fixture @pytest.fixture
def myfix(request): def myfix(request):
request.addfinalizer(l.pop) request.addfinalizer(values.pop)
assert 0 assert 0
def test_fix(myfix): def test_fix(myfix):
pass pass
def test_finalizer_ran(): def test_finalizer_ran():
assert not l assert not values
""") """)
reprec = testdir.inline_run("-s") reprec = testdir.inline_run("-s")
reprec.assertoutcome(failed=1, passed=1) reprec.assertoutcome(failed=1, passed=1)
@ -634,30 +634,30 @@ class TestRequestBasic(object):
def test_request_addfinalizer_failing_setup_module(self, testdir): def test_request_addfinalizer_failing_setup_module(self, testdir):
testdir.makepyfile(""" testdir.makepyfile("""
import pytest import pytest
l = [1, 2] values = [1, 2]
@pytest.fixture(scope="module") @pytest.fixture(scope="module")
def myfix(request): def myfix(request):
request.addfinalizer(l.pop) request.addfinalizer(values.pop)
request.addfinalizer(l.pop) request.addfinalizer(values.pop)
assert 0 assert 0
def test_fix(myfix): def test_fix(myfix):
pass pass
""") """)
reprec = testdir.inline_run("-s") reprec = testdir.inline_run("-s")
mod = reprec.getcalls("pytest_runtest_setup")[0].item.module mod = reprec.getcalls("pytest_runtest_setup")[0].item.module
assert not mod.l assert not mod.values
def test_request_addfinalizer_partial_setup_failure(self, testdir): def test_request_addfinalizer_partial_setup_failure(self, testdir):
p = testdir.makepyfile(""" p = testdir.makepyfile("""
import pytest import pytest
l = [] values = []
@pytest.fixture @pytest.fixture
def something(request): def something(request):
request.addfinalizer(lambda: l.append(None)) request.addfinalizer(lambda: values.append(None))
def test_func(something, missingarg): def test_func(something, missingarg):
pass pass
def test_second(): def test_second():
assert len(l) == 1 assert len(values) == 1
""") """)
result = testdir.runpytest(p) result = testdir.runpytest(p)
result.stdout.fnmatch_lines([ result.stdout.fnmatch_lines([
@ -671,7 +671,7 @@ class TestRequestBasic(object):
""" """
testdir.makepyfile(""" testdir.makepyfile("""
import pytest import pytest
l = [] values = []
def _excepts(where): def _excepts(where):
raise Exception('Error in %s fixture' % where) raise Exception('Error in %s fixture' % where)
@pytest.fixture @pytest.fixture
@ -679,17 +679,17 @@ class TestRequestBasic(object):
return request return request
@pytest.fixture @pytest.fixture
def something(subrequest): def something(subrequest):
subrequest.addfinalizer(lambda: l.append(1)) subrequest.addfinalizer(lambda: values.append(1))
subrequest.addfinalizer(lambda: l.append(2)) subrequest.addfinalizer(lambda: values.append(2))
subrequest.addfinalizer(lambda: _excepts('something')) subrequest.addfinalizer(lambda: _excepts('something'))
@pytest.fixture @pytest.fixture
def excepts(subrequest): def excepts(subrequest):
subrequest.addfinalizer(lambda: _excepts('excepts')) subrequest.addfinalizer(lambda: _excepts('excepts'))
subrequest.addfinalizer(lambda: l.append(3)) subrequest.addfinalizer(lambda: values.append(3))
def test_first(something, excepts): def test_first(something, excepts):
pass pass
def test_second(): def test_second():
assert l == [3, 2, 1] assert values == [3, 2, 1]
""") """)
result = testdir.runpytest() result = testdir.runpytest()
result.stdout.fnmatch_lines([ result.stdout.fnmatch_lines([
@ -744,13 +744,13 @@ class TestRequestBasic(object):
def test_setupdecorator_and_xunit(self, testdir): def test_setupdecorator_and_xunit(self, testdir):
testdir.makepyfile(""" testdir.makepyfile("""
import pytest import pytest
l = [] values = []
@pytest.fixture(scope='module', autouse=True) @pytest.fixture(scope='module', autouse=True)
def setup_module(): def setup_module():
l.append("module") values.append("module")
@pytest.fixture(autouse=True) @pytest.fixture(autouse=True)
def setup_function(): def setup_function():
l.append("function") values.append("function")
def test_func(): def test_func():
pass pass
@ -758,14 +758,14 @@ class TestRequestBasic(object):
class TestClass(object): class TestClass(object):
@pytest.fixture(scope="class", autouse=True) @pytest.fixture(scope="class", autouse=True)
def setup_class(self): def setup_class(self):
l.append("class") values.append("class")
@pytest.fixture(autouse=True) @pytest.fixture(autouse=True)
def setup_method(self): def setup_method(self):
l.append("method") values.append("method")
def test_method(self): def test_method(self):
pass pass
def test_all(): def test_all():
assert l == ["module", "function", "class", assert values == ["module", "function", "class",
"function", "method", "function"] "function", "method", "function"]
""") """)
reprec = testdir.inline_run("-v") reprec = testdir.inline_run("-v")
@ -926,10 +926,10 @@ class TestRequestCachedSetup(object):
def test_request_cachedsetup_extrakey(self, testdir): def test_request_cachedsetup_extrakey(self, testdir):
item1 = testdir.getitem("def test_func(): pass") item1 = testdir.getitem("def test_func(): pass")
req1 = fixtures.FixtureRequest(item1) req1 = fixtures.FixtureRequest(item1)
l = ["hello", "world"] values = ["hello", "world"]
def setup(): def setup():
return l.pop() return values.pop()
ret1 = req1.cached_setup(setup, extrakey=1) ret1 = req1.cached_setup(setup, extrakey=1)
ret2 = req1.cached_setup(setup, extrakey=2) ret2 = req1.cached_setup(setup, extrakey=2)
@ -943,24 +943,24 @@ class TestRequestCachedSetup(object):
def test_request_cachedsetup_cache_deletion(self, testdir): def test_request_cachedsetup_cache_deletion(self, testdir):
item1 = testdir.getitem("def test_func(): pass") item1 = testdir.getitem("def test_func(): pass")
req1 = fixtures.FixtureRequest(item1) req1 = fixtures.FixtureRequest(item1)
l = [] values = []
def setup(): def setup():
l.append("setup") values.append("setup")
def teardown(val): def teardown(val):
l.append("teardown") values.append("teardown")
req1.cached_setup(setup, teardown, scope="function") req1.cached_setup(setup, teardown, scope="function")
assert l == ['setup'] assert values == ['setup']
# artificial call of finalizer # artificial call of finalizer
setupstate = req1._pyfuncitem.session._setupstate setupstate = req1._pyfuncitem.session._setupstate
setupstate._callfinalizers(item1) setupstate._callfinalizers(item1)
assert l == ["setup", "teardown"] assert values == ["setup", "teardown"]
req1.cached_setup(setup, teardown, scope="function") req1.cached_setup(setup, teardown, scope="function")
assert l == ["setup", "teardown", "setup"] assert values == ["setup", "teardown", "setup"]
setupstate._callfinalizers(item1) setupstate._callfinalizers(item1)
assert l == ["setup", "teardown", "setup", "teardown"] assert values == ["setup", "teardown", "setup", "teardown"]
def test_request_cached_setup_two_args(self, testdir): def test_request_cached_setup_two_args(self, testdir):
testdir.makepyfile(""" testdir.makepyfile("""
@ -1002,17 +1002,17 @@ class TestRequestCachedSetup(object):
def test_request_cached_setup_functional(self, testdir): def test_request_cached_setup_functional(self, testdir):
testdir.makepyfile(test_0=""" testdir.makepyfile(test_0="""
import pytest import pytest
l = [] values = []
@pytest.fixture @pytest.fixture
def something(request): def something(request):
val = request.cached_setup(fsetup, fteardown) val = request.cached_setup(fsetup, fteardown)
return val return val
def fsetup(mycache=[1]): def fsetup(mycache=[1]):
l.append(mycache.pop()) values.append(mycache.pop())
return l return values
def fteardown(something): def fteardown(something):
l.remove(something[0]) values.remove(something[0])
l.append(2) values.append(2)
def test_list_once(something): def test_list_once(something):
assert something == [1] assert something == [1]
def test_list_twice(something): def test_list_twice(something):
@ -1021,7 +1021,7 @@ class TestRequestCachedSetup(object):
testdir.makepyfile(test_1=""" testdir.makepyfile(test_1="""
import test_0 # should have run already import test_0 # should have run already
def test_check_test0_has_teardown_correct(): def test_check_test0_has_teardown_correct():
assert test_0.l == [2] assert test_0.values == [2]
""") """)
result = testdir.runpytest("-v") result = testdir.runpytest("-v")
result.stdout.fnmatch_lines([ result.stdout.fnmatch_lines([
@ -1146,10 +1146,10 @@ class TestFixtureUsages(object):
def test_funcarg_parametrized_and_used_twice(self, testdir): def test_funcarg_parametrized_and_used_twice(self, testdir):
testdir.makepyfile(""" testdir.makepyfile("""
import pytest import pytest
l = [] values = []
@pytest.fixture(params=[1,2]) @pytest.fixture(params=[1,2])
def arg1(request): def arg1(request):
l.append(1) values.append(1)
return request.param return request.param
@pytest.fixture() @pytest.fixture()
@ -1158,7 +1158,7 @@ class TestFixtureUsages(object):
def test_add(arg1, arg2): def test_add(arg1, arg2):
assert arg2 == arg1 + 1 assert arg2 == arg1 + 1
assert len(l) == arg1 assert len(values) == arg1
""") """)
result = testdir.runpytest() result = testdir.runpytest()
result.stdout.fnmatch_lines([ result.stdout.fnmatch_lines([
@ -1199,8 +1199,8 @@ class TestFixtureUsages(object):
""") """)
reprec = testdir.inline_run() reprec = testdir.inline_run()
l = reprec.getfailedcollections() values = reprec.getfailedcollections()
assert len(l) == 1 assert len(values) == 1
def test_request_can_be_overridden(self, testdir): def test_request_can_be_overridden(self, testdir):
testdir.makepyfile(""" testdir.makepyfile("""
@ -1219,20 +1219,20 @@ class TestFixtureUsages(object):
testdir.makepyfile(""" testdir.makepyfile("""
import pytest import pytest
l = [] values = []
@pytest.fixture(scope="class") @pytest.fixture(scope="class")
def myfix(request): def myfix(request):
request.cls.hello = "world" request.cls.hello = "world"
l.append(1) values.append(1)
class TestClass(object): class TestClass(object):
def test_one(self): def test_one(self):
assert self.hello == "world" assert self.hello == "world"
assert len(l) == 1 assert len(values) == 1
def test_two(self): def test_two(self):
assert self.hello == "world" assert self.hello == "world"
assert len(l) == 1 assert len(values) == 1
pytest.mark.usefixtures("myfix")(TestClass) pytest.mark.usefixtures("myfix")(TestClass)
""") """)
reprec = testdir.inline_run() reprec = testdir.inline_run()
@ -1286,7 +1286,7 @@ class TestFixtureUsages(object):
testdir.makepyfile(""" testdir.makepyfile("""
import pytest import pytest
l = [] values = []
def f(): def f():
yield 1 yield 1
yield 2 yield 2
@ -1300,14 +1300,14 @@ class TestFixtureUsages(object):
return request.param return request.param
def test_1(arg): def test_1(arg):
l.append(arg) values.append(arg)
def test_2(arg2): def test_2(arg2):
l.append(arg2*10) values.append(arg2*10)
""") """)
reprec = testdir.inline_run("-v") reprec = testdir.inline_run("-v")
reprec.assertoutcome(passed=4) reprec.assertoutcome(passed=4)
l = reprec.getcalls("pytest_runtest_call")[0].item.module.l values = reprec.getcalls("pytest_runtest_call")[0].item.module.values
assert l == [1, 2, 10, 20] assert values == [1, 2, 10, 20]
class TestFixtureManagerParseFactories(object): class TestFixtureManagerParseFactories(object):
@ -1457,19 +1457,19 @@ class TestAutouseDiscovery(object):
testdir.makepyfile(""" testdir.makepyfile("""
import pytest import pytest
class TestA(object): class TestA(object):
l = [] values = []
@pytest.fixture(autouse=True) @pytest.fixture(autouse=True)
def setup1(self): def setup1(self):
self.l.append(1) self.values.append(1)
def test_setup1(self): def test_setup1(self):
assert self.l == [1] assert self.values == [1]
class TestB(object): class TestB(object):
l = [] values = []
@pytest.fixture(autouse=True) @pytest.fixture(autouse=True)
def setup2(self): def setup2(self):
self.l.append(1) self.values.append(1)
def test_setup2(self): def test_setup2(self):
assert self.l == [1] assert self.values == [1]
""") """)
reprec = testdir.inline_run() reprec = testdir.inline_run()
reprec.assertoutcome(passed=2) reprec.assertoutcome(passed=2)
@ -1552,22 +1552,22 @@ class TestAutouseDiscovery(object):
def test_autouse_in_module_and_two_classes(self, testdir): def test_autouse_in_module_and_two_classes(self, testdir):
testdir.makepyfile(""" testdir.makepyfile("""
import pytest import pytest
l = [] values = []
@pytest.fixture(autouse=True) @pytest.fixture(autouse=True)
def append1(): def append1():
l.append("module") values.append("module")
def test_x(): def test_x():
assert l == ["module"] assert values == ["module"]
class TestA(object): class TestA(object):
@pytest.fixture(autouse=True) @pytest.fixture(autouse=True)
def append2(self): def append2(self):
l.append("A") values.append("A")
def test_hello(self): def test_hello(self):
assert l == ["module", "module", "A"], l assert values == ["module", "module", "A"], values
class TestA2(object): class TestA2(object):
def test_world(self): def test_world(self):
assert l == ["module", "module", "A", "module"], l assert values == ["module", "module", "A", "module"], values
""") """)
reprec = testdir.inline_run() reprec = testdir.inline_run()
reprec.assertoutcome(passed=3) reprec.assertoutcome(passed=3)
@ -1611,23 +1611,23 @@ class TestAutouseManagement(object):
def test_funcarg_and_setup(self, testdir): def test_funcarg_and_setup(self, testdir):
testdir.makepyfile(""" testdir.makepyfile("""
import pytest import pytest
l = [] values = []
@pytest.fixture(scope="module") @pytest.fixture(scope="module")
def arg(): def arg():
l.append(1) values.append(1)
return 0 return 0
@pytest.fixture(scope="module", autouse=True) @pytest.fixture(scope="module", autouse=True)
def something(arg): def something(arg):
l.append(2) values.append(2)
def test_hello(arg): def test_hello(arg):
assert len(l) == 2 assert len(values) == 2
assert l == [1,2] assert values == [1,2]
assert arg == 0 assert arg == 0
def test_hello2(arg): def test_hello2(arg):
assert len(l) == 2 assert len(values) == 2
assert l == [1,2] assert values == [1,2]
assert arg == 0 assert arg == 0
""") """)
reprec = testdir.inline_run() reprec = testdir.inline_run()
@ -1636,20 +1636,20 @@ class TestAutouseManagement(object):
def test_uses_parametrized_resource(self, testdir): def test_uses_parametrized_resource(self, testdir):
testdir.makepyfile(""" testdir.makepyfile("""
import pytest import pytest
l = [] values = []
@pytest.fixture(params=[1,2]) @pytest.fixture(params=[1,2])
def arg(request): def arg(request):
return request.param return request.param
@pytest.fixture(autouse=True) @pytest.fixture(autouse=True)
def something(arg): def something(arg):
l.append(arg) values.append(arg)
def test_hello(): def test_hello():
if len(l) == 1: if len(values) == 1:
assert l == [1] assert values == [1]
elif len(l) == 2: elif len(values) == 2:
assert l == [1, 2] assert values == [1, 2]
else: else:
0/0 0/0
@ -1661,7 +1661,7 @@ class TestAutouseManagement(object):
testdir.makepyfile(""" testdir.makepyfile("""
import pytest import pytest
l = [] values = []
@pytest.fixture(scope="session", params=[1,2]) @pytest.fixture(scope="session", params=[1,2])
def arg(request): def arg(request):
@ -1670,14 +1670,14 @@ class TestAutouseManagement(object):
@pytest.fixture(scope="function", autouse=True) @pytest.fixture(scope="function", autouse=True)
def append(request, arg): def append(request, arg):
if request.function.__name__ == "test_some": if request.function.__name__ == "test_some":
l.append(arg) values.append(arg)
def test_some(): def test_some():
pass pass
def test_result(arg): def test_result(arg):
assert len(l) == arg assert len(values) == arg
assert l[:arg] == [1,2][:arg] assert values[:arg] == [1,2][:arg]
""") """)
reprec = testdir.inline_run("-v", "-s") reprec = testdir.inline_run("-v", "-s")
reprec.assertoutcome(passed=4) reprec.assertoutcome(passed=4)
@ -1687,7 +1687,7 @@ class TestAutouseManagement(object):
import pytest import pytest
import pprint import pprint
l = [] values = []
@pytest.fixture(scope="function", params=[1,2]) @pytest.fixture(scope="function", params=[1,2])
def farg(request): def farg(request):
@ -1700,7 +1700,7 @@ class TestAutouseManagement(object):
@pytest.fixture(scope="function", autouse=True) @pytest.fixture(scope="function", autouse=True)
def append(request, farg, carg): def append(request, farg, carg):
def fin(): def fin():
l.append("fin_%s%s" % (carg, farg)) values.append("fin_%s%s" % (carg, farg))
request.addfinalizer(fin) request.addfinalizer(fin)
""") """)
testdir.makepyfile(""" testdir.makepyfile("""
@ -1717,26 +1717,26 @@ class TestAutouseManagement(object):
reprec = testdir.inline_run("-v", "-s", confcut) reprec = testdir.inline_run("-v", "-s", confcut)
reprec.assertoutcome(passed=8) reprec.assertoutcome(passed=8)
config = reprec.getcalls("pytest_unconfigure")[0].config config = reprec.getcalls("pytest_unconfigure")[0].config
l = config.pluginmanager._getconftestmodules(p)[0].l values = config.pluginmanager._getconftestmodules(p)[0].values
assert l == ["fin_a1", "fin_a2", "fin_b1", "fin_b2"] * 2 assert values == ["fin_a1", "fin_a2", "fin_b1", "fin_b2"] * 2
def test_scope_ordering(self, testdir): def test_scope_ordering(self, testdir):
testdir.makepyfile(""" testdir.makepyfile("""
import pytest import pytest
l = [] values = []
@pytest.fixture(scope="function", autouse=True) @pytest.fixture(scope="function", autouse=True)
def fappend2(): def fappend2():
l.append(2) values.append(2)
@pytest.fixture(scope="class", autouse=True) @pytest.fixture(scope="class", autouse=True)
def classappend3(): def classappend3():
l.append(3) values.append(3)
@pytest.fixture(scope="module", autouse=True) @pytest.fixture(scope="module", autouse=True)
def mappend(): def mappend():
l.append(1) values.append(1)
class TestHallo(object): class TestHallo(object):
def test_method(self): def test_method(self):
assert l == [1,3,2] assert values == [1,3,2]
""") """)
reprec = testdir.inline_run() reprec = testdir.inline_run()
reprec.assertoutcome(passed=1) reprec.assertoutcome(passed=1)
@ -1744,23 +1744,23 @@ class TestAutouseManagement(object):
def test_parametrization_setup_teardown_ordering(self, testdir): def test_parametrization_setup_teardown_ordering(self, testdir):
testdir.makepyfile(""" testdir.makepyfile("""
import pytest import pytest
l = [] values = []
def pytest_generate_tests(metafunc): def pytest_generate_tests(metafunc):
if metafunc.cls is not None: if metafunc.cls is not None:
metafunc.parametrize("item", [1,2], scope="class") metafunc.parametrize("item", [1,2], scope="class")
class TestClass(object): class TestClass(object):
@pytest.fixture(scope="class", autouse=True) @pytest.fixture(scope="class", autouse=True)
def addteardown(self, item, request): def addteardown(self, item, request):
l.append("setup-%d" % item) values.append("setup-%d" % item)
request.addfinalizer(lambda: l.append("teardown-%d" % item)) request.addfinalizer(lambda: values.append("teardown-%d" % item))
def test_step1(self, item): def test_step1(self, item):
l.append("step1-%d" % item) values.append("step1-%d" % item)
def test_step2(self, item): def test_step2(self, item):
l.append("step2-%d" % item) values.append("step2-%d" % item)
def test_finish(): def test_finish():
print (l) print (values)
assert l == ["setup-1", "step1-1", "step2-1", "teardown-1", assert values == ["setup-1", "step1-1", "step2-1", "teardown-1",
"setup-2", "step1-2", "step2-2", "teardown-2",] "setup-2", "step1-2", "step2-2", "teardown-2",]
""") """)
reprec = testdir.inline_run() reprec = testdir.inline_run()
@ -1770,15 +1770,15 @@ class TestAutouseManagement(object):
testdir.makepyfile(""" testdir.makepyfile("""
import pytest import pytest
l = [] values = []
@pytest.fixture(autouse=True) @pytest.fixture(autouse=True)
def fix1(): def fix1():
l.append(1) values.append(1)
@pytest.fixture() @pytest.fixture()
def arg1(): def arg1():
l.append(2) values.append(2)
def test_hello(arg1): def test_hello(arg1):
assert l == [1,2] assert values == [1,2]
""") """)
reprec = testdir.inline_run() reprec = testdir.inline_run()
reprec.assertoutcome(passed=1) reprec.assertoutcome(passed=1)
@ -1789,20 +1789,20 @@ class TestAutouseManagement(object):
def test_ordering_dependencies_torndown_first(self, testdir, param1, param2): def test_ordering_dependencies_torndown_first(self, testdir, param1, param2):
testdir.makepyfile(""" testdir.makepyfile("""
import pytest import pytest
l = [] values = []
@pytest.fixture(%(param1)s) @pytest.fixture(%(param1)s)
def arg1(request): def arg1(request):
request.addfinalizer(lambda: l.append("fin1")) request.addfinalizer(lambda: values.append("fin1"))
l.append("new1") values.append("new1")
@pytest.fixture(%(param2)s) @pytest.fixture(%(param2)s)
def arg2(request, arg1): def arg2(request, arg1):
request.addfinalizer(lambda: l.append("fin2")) request.addfinalizer(lambda: values.append("fin2"))
l.append("new2") values.append("new2")
def test_arg(arg2): def test_arg(arg2):
pass pass
def test_check(): def test_check():
assert l == ["new1", "new2", "fin2", "fin1"] assert values == ["new1", "new2", "fin2", "fin1"]
""" % locals()) """ % locals())
reprec = testdir.inline_run("-s") reprec = testdir.inline_run("-s")
reprec.assertoutcome(passed=2) reprec.assertoutcome(passed=2)
@ -1815,11 +1815,11 @@ class TestFixtureMarker(object):
@pytest.fixture(params=["a", "b", "c"]) @pytest.fixture(params=["a", "b", "c"])
def arg(request): def arg(request):
return request.param return request.param
l = [] values = []
def test_param(arg): def test_param(arg):
l.append(arg) values.append(arg)
def test_result(): def test_result():
assert l == list("abc") assert values == list("abc")
""") """)
reprec = testdir.inline_run() reprec = testdir.inline_run()
reprec.assertoutcome(passed=4) reprec.assertoutcome(passed=4)
@ -1863,21 +1863,21 @@ class TestFixtureMarker(object):
def test_scope_session(self, testdir): def test_scope_session(self, testdir):
testdir.makepyfile(""" testdir.makepyfile("""
import pytest import pytest
l = [] values = []
@pytest.fixture(scope="module") @pytest.fixture(scope="module")
def arg(): def arg():
l.append(1) values.append(1)
return 1 return 1
def test_1(arg): def test_1(arg):
assert arg == 1 assert arg == 1
def test_2(arg): def test_2(arg):
assert arg == 1 assert arg == 1
assert len(l) == 1 assert len(values) == 1
class TestClass(object): class TestClass(object):
def test3(self, arg): def test3(self, arg):
assert arg == 1 assert arg == 1
assert len(l) == 1 assert len(values) == 1
""") """)
reprec = testdir.inline_run() reprec = testdir.inline_run()
reprec.assertoutcome(passed=3) reprec.assertoutcome(passed=3)
@ -1885,10 +1885,10 @@ class TestFixtureMarker(object):
def test_scope_session_exc(self, testdir): def test_scope_session_exc(self, testdir):
testdir.makepyfile(""" testdir.makepyfile("""
import pytest import pytest
l = [] values = []
@pytest.fixture(scope="session") @pytest.fixture(scope="session")
def fix(): def fix():
l.append(1) values.append(1)
pytest.skip('skipping') pytest.skip('skipping')
def test_1(fix): def test_1(fix):
@ -1896,7 +1896,7 @@ class TestFixtureMarker(object):
def test_2(fix): def test_2(fix):
pass pass
def test_last(): def test_last():
assert l == [1] assert values == [1]
""") """)
reprec = testdir.inline_run() reprec = testdir.inline_run()
reprec.assertoutcome(skipped=2, passed=1) reprec.assertoutcome(skipped=2, passed=1)
@ -1904,11 +1904,11 @@ class TestFixtureMarker(object):
def test_scope_session_exc_two_fix(self, testdir): def test_scope_session_exc_two_fix(self, testdir):
testdir.makepyfile(""" testdir.makepyfile("""
import pytest import pytest
l = [] values = []
m = [] m = []
@pytest.fixture(scope="session") @pytest.fixture(scope="session")
def a(): def a():
l.append(1) values.append(1)
pytest.skip('skipping') pytest.skip('skipping')
@pytest.fixture(scope="session") @pytest.fixture(scope="session")
def b(a): def b(a):
@ -1919,7 +1919,7 @@ class TestFixtureMarker(object):
def test_2(b): def test_2(b):
pass pass
def test_last(): def test_last():
assert l == [1] assert values == [1]
assert m == [] assert m == []
""") """)
reprec = testdir.inline_run() reprec = testdir.inline_run()
@ -1957,21 +1957,21 @@ class TestFixtureMarker(object):
def test_scope_module_uses_session(self, testdir): def test_scope_module_uses_session(self, testdir):
testdir.makepyfile(""" testdir.makepyfile("""
import pytest import pytest
l = [] values = []
@pytest.fixture(scope="module") @pytest.fixture(scope="module")
def arg(): def arg():
l.append(1) values.append(1)
return 1 return 1
def test_1(arg): def test_1(arg):
assert arg == 1 assert arg == 1
def test_2(arg): def test_2(arg):
assert arg == 1 assert arg == 1
assert len(l) == 1 assert len(values) == 1
class TestClass(object): class TestClass(object):
def test3(self, arg): def test3(self, arg):
assert arg == 1 assert arg == 1
assert len(l) == 1 assert len(values) == 1
""") """)
reprec = testdir.inline_run() reprec = testdir.inline_run()
reprec.assertoutcome(passed=3) reprec.assertoutcome(passed=3)
@ -2066,17 +2066,17 @@ class TestFixtureMarker(object):
@pytest.fixture(scope="module", params=["a", "b", "c"]) @pytest.fixture(scope="module", params=["a", "b", "c"])
def arg(request): def arg(request):
return request.param return request.param
l = [] values = []
def test_param(arg): def test_param(arg):
l.append(arg) values.append(arg)
""") """)
reprec = testdir.inline_run("-v") reprec = testdir.inline_run("-v")
reprec.assertoutcome(passed=3) reprec.assertoutcome(passed=3)
l = reprec.getcalls("pytest_runtest_call")[0].item.module.l values = reprec.getcalls("pytest_runtest_call")[0].item.module.values
assert len(l) == 3 assert len(values) == 3
assert "a" in l assert "a" in values
assert "b" in l assert "b" in values
assert "c" in l assert "c" in values
def test_scope_mismatch(self, testdir): def test_scope_mismatch(self, testdir):
testdir.makeconftest(""" testdir.makeconftest("""
@ -2107,16 +2107,16 @@ class TestFixtureMarker(object):
def arg(request): def arg(request):
return request.param return request.param
l = [] values = []
def test_1(arg): def test_1(arg):
l.append(arg) values.append(arg)
def test_2(arg): def test_2(arg):
l.append(arg) values.append(arg)
""") """)
reprec = testdir.inline_run("-v") reprec = testdir.inline_run("-v")
reprec.assertoutcome(passed=4) reprec.assertoutcome(passed=4)
l = reprec.getcalls("pytest_runtest_call")[0].item.module.l values = reprec.getcalls("pytest_runtest_call")[0].item.module.values
assert l == [1, 1, 2, 2] assert values == [1, 1, 2, 2]
def test_module_parametrized_ordering(self, testdir): def test_module_parametrized_ordering(self, testdir):
testdir.makeconftest(""" testdir.makeconftest("""
@ -2168,7 +2168,7 @@ class TestFixtureMarker(object):
testdir.makeconftest(""" testdir.makeconftest("""
import pytest import pytest
l = [] values = []
@pytest.fixture(scope="function", params=[1,2]) @pytest.fixture(scope="function", params=[1,2])
def farg(request): def farg(request):
@ -2181,7 +2181,7 @@ class TestFixtureMarker(object):
@pytest.fixture(scope="function", autouse=True) @pytest.fixture(scope="function", autouse=True)
def append(request, farg, carg): def append(request, farg, carg):
def fin(): def fin():
l.append("fin_%s%s" % (carg, farg)) values.append("fin_%s%s" % (carg, farg))
request.addfinalizer(fin) request.addfinalizer(fin)
""") """)
testdir.makepyfile(""" testdir.makepyfile("""
@ -2219,30 +2219,30 @@ class TestFixtureMarker(object):
@pytest.fixture(scope="function", params=[1, 2]) @pytest.fixture(scope="function", params=[1, 2])
def arg(request): def arg(request):
param = request.param param = request.param
request.addfinalizer(lambda: l.append("fin:%s" % param)) request.addfinalizer(lambda: values.append("fin:%s" % param))
l.append("create:%s" % param) values.append("create:%s" % param)
return request.param return request.param
@pytest.fixture(scope="module", params=["mod1", "mod2"]) @pytest.fixture(scope="module", params=["mod1", "mod2"])
def modarg(request): def modarg(request):
param = request.param param = request.param
request.addfinalizer(lambda: l.append("fin:%s" % param)) request.addfinalizer(lambda: values.append("fin:%s" % param))
l.append("create:%s" % param) values.append("create:%s" % param)
return request.param return request.param
l = [] values = []
def test_1(arg): def test_1(arg):
l.append("test1") values.append("test1")
def test_2(modarg): def test_2(modarg):
l.append("test2") values.append("test2")
def test_3(arg, modarg): def test_3(arg, modarg):
l.append("test3") values.append("test3")
def test_4(modarg, arg): def test_4(modarg, arg):
l.append("test4") values.append("test4")
""") """)
reprec = testdir.inline_run("-v") reprec = testdir.inline_run("-v")
reprec.assertoutcome(passed=12) reprec.assertoutcome(passed=12)
l = reprec.getcalls("pytest_runtest_call")[0].item.module.l values = reprec.getcalls("pytest_runtest_call")[0].item.module.values
expected = [ expected = [
'create:1', 'test1', 'fin:1', 'create:2', 'test1', 'create:1', 'test1', 'fin:1', 'create:2', 'test1',
'fin:2', 'create:mod1', 'test2', 'create:1', 'test3', 'fin:2', 'create:mod1', 'test2', 'create:1', 'test3',
@ -2253,8 +2253,8 @@ class TestFixtureMarker(object):
'test4', 'fin:1', 'create:2', 'test4', 'fin:2', 'test4', 'fin:1', 'create:2', 'test4', 'fin:2',
'fin:mod2'] 'fin:mod2']
import pprint import pprint
pprint.pprint(list(zip(l, expected))) pprint.pprint(list(zip(values, expected)))
assert l == expected assert values == expected
def test_parametrized_fixture_teardown_order(self, testdir): def test_parametrized_fixture_teardown_order(self, testdir):
testdir.makepyfile(""" testdir.makepyfile("""
@ -2263,29 +2263,29 @@ class TestFixtureMarker(object):
def param1(request): def param1(request):
return request.param return request.param
l = [] values = []
class TestClass(object): class TestClass(object):
@classmethod @classmethod
@pytest.fixture(scope="class", autouse=True) @pytest.fixture(scope="class", autouse=True)
def setup1(self, request, param1): def setup1(self, request, param1):
l.append(1) values.append(1)
request.addfinalizer(self.teardown1) request.addfinalizer(self.teardown1)
@classmethod @classmethod
def teardown1(self): def teardown1(self):
assert l.pop() == 1 assert values.pop() == 1
@pytest.fixture(scope="class", autouse=True) @pytest.fixture(scope="class", autouse=True)
def setup2(self, request, param1): def setup2(self, request, param1):
l.append(2) values.append(2)
request.addfinalizer(self.teardown2) request.addfinalizer(self.teardown2)
@classmethod @classmethod
def teardown2(self): def teardown2(self):
assert l.pop() == 2 assert values.pop() == 2
def test(self): def test(self):
pass pass
def test_finish(): def test_finish():
assert not l assert not values
""") """)
result = testdir.runpytest("-v") result = testdir.runpytest("-v")
result.stdout.fnmatch_lines(""" result.stdout.fnmatch_lines("""
@ -2350,42 +2350,42 @@ class TestFixtureMarker(object):
def test_request_is_clean(self, testdir): def test_request_is_clean(self, testdir):
testdir.makepyfile(""" testdir.makepyfile("""
import pytest import pytest
l = [] values = []
@pytest.fixture(params=[1, 2]) @pytest.fixture(params=[1, 2])
def fix(request): def fix(request):
request.addfinalizer(lambda: l.append(request.param)) request.addfinalizer(lambda: values.append(request.param))
def test_fix(fix): def test_fix(fix):
pass pass
""") """)
reprec = testdir.inline_run("-s") reprec = testdir.inline_run("-s")
l = reprec.getcalls("pytest_runtest_call")[0].item.module.l values = reprec.getcalls("pytest_runtest_call")[0].item.module.values
assert l == [1, 2] assert values == [1, 2]
def test_parametrize_separated_lifecycle(self, testdir): def test_parametrize_separated_lifecycle(self, testdir):
testdir.makepyfile(""" testdir.makepyfile("""
import pytest import pytest
l = [] values = []
@pytest.fixture(scope="module", params=[1, 2]) @pytest.fixture(scope="module", params=[1, 2])
def arg(request): def arg(request):
x = request.param x = request.param
request.addfinalizer(lambda: l.append("fin%s" % x)) request.addfinalizer(lambda: values.append("fin%s" % x))
return request.param return request.param
def test_1(arg): def test_1(arg):
l.append(arg) values.append(arg)
def test_2(arg): def test_2(arg):
l.append(arg) values.append(arg)
""") """)
reprec = testdir.inline_run("-vs") reprec = testdir.inline_run("-vs")
reprec.assertoutcome(passed=4) reprec.assertoutcome(passed=4)
l = reprec.getcalls("pytest_runtest_call")[0].item.module.l values = reprec.getcalls("pytest_runtest_call")[0].item.module.values
import pprint import pprint
pprint.pprint(l) pprint.pprint(values)
# assert len(l) == 6 # assert len(values) == 6
assert l[0] == l[1] == 1 assert values[0] == values[1] == 1
assert l[2] == "fin1" assert values[2] == "fin1"
assert l[3] == l[4] == 2 assert values[3] == values[4] == 2
assert l[5] == "fin2" assert values[5] == "fin2"
def test_parametrize_function_scoped_finalizers_called(self, testdir): def test_parametrize_function_scoped_finalizers_called(self, testdir):
testdir.makepyfile(""" testdir.makepyfile("""
@ -2394,17 +2394,17 @@ class TestFixtureMarker(object):
@pytest.fixture(scope="function", params=[1, 2]) @pytest.fixture(scope="function", params=[1, 2])
def arg(request): def arg(request):
x = request.param x = request.param
request.addfinalizer(lambda: l.append("fin%s" % x)) request.addfinalizer(lambda: values.append("fin%s" % x))
return request.param return request.param
l = [] values = []
def test_1(arg): def test_1(arg):
l.append(arg) values.append(arg)
def test_2(arg): def test_2(arg):
l.append(arg) values.append(arg)
def test_3(): def test_3():
assert len(l) == 8 assert len(values) == 8
assert l == [1, "fin1", 2, "fin2", 1, "fin1", 2, "fin2"] assert values == [1, "fin1", 2, "fin2", 1, "fin1", 2, "fin2"]
""") """)
reprec = testdir.inline_run("-v") reprec = testdir.inline_run("-v")
reprec.assertoutcome(passed=5) reprec.assertoutcome(passed=5)
@ -2414,7 +2414,7 @@ class TestFixtureMarker(object):
def test_finalizer_order_on_parametrization(self, scope, testdir): def test_finalizer_order_on_parametrization(self, scope, testdir):
testdir.makepyfile(""" testdir.makepyfile("""
import pytest import pytest
l = [] values = []
@pytest.fixture(scope=%(scope)r, params=["1"]) @pytest.fixture(scope=%(scope)r, params=["1"])
def fix1(request): def fix1(request):
@ -2423,13 +2423,13 @@ class TestFixtureMarker(object):
@pytest.fixture(scope=%(scope)r) @pytest.fixture(scope=%(scope)r)
def fix2(request, base): def fix2(request, base):
def cleanup_fix2(): def cleanup_fix2():
assert not l, "base should not have been finalized" assert not values, "base should not have been finalized"
request.addfinalizer(cleanup_fix2) request.addfinalizer(cleanup_fix2)
@pytest.fixture(scope=%(scope)r) @pytest.fixture(scope=%(scope)r)
def base(request, fix1): def base(request, fix1):
def cleanup_base(): def cleanup_base():
l.append("fin_base") values.append("fin_base")
print ("finalizing base") print ("finalizing base")
request.addfinalizer(cleanup_base) request.addfinalizer(cleanup_base)
@ -2447,29 +2447,29 @@ class TestFixtureMarker(object):
def test_class_scope_parametrization_ordering(self, testdir): def test_class_scope_parametrization_ordering(self, testdir):
testdir.makepyfile(""" testdir.makepyfile("""
import pytest import pytest
l = [] values = []
@pytest.fixture(params=["John", "Doe"], scope="class") @pytest.fixture(params=["John", "Doe"], scope="class")
def human(request): def human(request):
request.addfinalizer(lambda: l.append("fin %s" % request.param)) request.addfinalizer(lambda: values.append("fin %s" % request.param))
return request.param return request.param
class TestGreetings(object): class TestGreetings(object):
def test_hello(self, human): def test_hello(self, human):
l.append("test_hello") values.append("test_hello")
class TestMetrics(object): class TestMetrics(object):
def test_name(self, human): def test_name(self, human):
l.append("test_name") values.append("test_name")
def test_population(self, human): def test_population(self, human):
l.append("test_population") values.append("test_population")
""") """)
reprec = testdir.inline_run() reprec = testdir.inline_run()
reprec.assertoutcome(passed=6) reprec.assertoutcome(passed=6)
l = reprec.getcalls("pytest_runtest_call")[0].item.module.l values = reprec.getcalls("pytest_runtest_call")[0].item.module.values
assert l == ["test_hello", "fin John", "test_hello", "fin Doe", assert values == ["test_hello", "fin John", "test_hello", "fin Doe",
"test_name", "test_population", "fin John", "test_name", "test_population", "fin John",
"test_name", "test_population", "fin Doe"] "test_name", "test_population", "fin Doe"]
def test_parametrize_setup_function(self, testdir): def test_parametrize_setup_function(self, testdir):
testdir.makepyfile(""" testdir.makepyfile("""
@ -2481,21 +2481,21 @@ class TestFixtureMarker(object):
@pytest.fixture(scope="module", autouse=True) @pytest.fixture(scope="module", autouse=True)
def mysetup(request, arg): def mysetup(request, arg):
request.addfinalizer(lambda: l.append("fin%s" % arg)) request.addfinalizer(lambda: values.append("fin%s" % arg))
l.append("setup%s" % arg) values.append("setup%s" % arg)
l = [] values = []
def test_1(arg): def test_1(arg):
l.append(arg) values.append(arg)
def test_2(arg): def test_2(arg):
l.append(arg) values.append(arg)
def test_3(): def test_3():
import pprint import pprint
pprint.pprint(l) pprint.pprint(values)
if arg == 1: if arg == 1:
assert l == ["setup1", 1, 1, ] assert values == ["setup1", 1, 1, ]
elif arg == 2: elif arg == 2:
assert l == ["setup1", 1, 1, "fin1", assert values == ["setup1", 1, 1, "fin1",
"setup2", 2, 2, ] "setup2", 2, 2, ]
""") """)
@ -2656,13 +2656,13 @@ class TestErrors(object):
request.addfinalizer(f) request.addfinalizer(f)
return object() return object()
l = [] values = []
def test_1(fix1): def test_1(fix1):
l.append(fix1) values.append(fix1)
def test_2(fix1): def test_2(fix1):
l.append(fix1) values.append(fix1)
def test_3(): def test_3():
assert l[0] != l[1] assert values[0] != values[1]
""") """)
result = testdir.runpytest() result = testdir.runpytest()
result.stdout.fnmatch_lines(""" result.stdout.fnmatch_lines("""

View File

@ -93,8 +93,8 @@ class TestMockDecoration(object):
def f(x): def f(x):
pass pass
l = getfuncargnames(f) values = getfuncargnames(f)
assert l == ("x",) assert values == ("x",)
def test_wrapped_getfuncargnames_patching(self): def test_wrapped_getfuncargnames_patching(self):
from _pytest.compat import getfuncargnames from _pytest.compat import getfuncargnames
@ -110,8 +110,8 @@ class TestMockDecoration(object):
def f(x, y, z): def f(x, y, z):
pass pass
l = getfuncargnames(f) values = getfuncargnames(f)
assert l == ("y", "z") assert values == ("y", "z")
def test_unittest_mock(self, testdir): def test_unittest_mock(self, testdir):
pytest.importorskip("unittest.mock") pytest.importorskip("unittest.mock")

View File

@ -1071,21 +1071,21 @@ class TestMetafuncFunctional(object):
def test_parametrize_scope_overrides(self, testdir, scope, length): def test_parametrize_scope_overrides(self, testdir, scope, length):
testdir.makepyfile(""" testdir.makepyfile("""
import pytest import pytest
l = [] values = []
def pytest_generate_tests(metafunc): def pytest_generate_tests(metafunc):
if "arg" in metafunc.funcargnames: if "arg" in metafunc.funcargnames:
metafunc.parametrize("arg", [1,2], indirect=True, metafunc.parametrize("arg", [1,2], indirect=True,
scope=%r) scope=%r)
@pytest.fixture @pytest.fixture
def arg(request): def arg(request):
l.append(request.param) values.append(request.param)
return request.param return request.param
def test_hello(arg): def test_hello(arg):
assert arg in (1,2) assert arg in (1,2)
def test_world(arg): def test_world(arg):
assert arg in (1,2) assert arg in (1,2)
def test_checklength(): def test_checklength():
assert len(l) == %d assert len(values) == %d
""" % (scope, length)) """ % (scope, length))
reprec = testdir.inline_run() reprec = testdir.inline_run()
reprec.assertoutcome(passed=5) reprec.assertoutcome(passed=5)

View File

@ -229,9 +229,9 @@ class TestImportHookInstallation(object):
return pkg.helper.tool return pkg.helper.tool
""", """,
'pkg/other.py': """ 'pkg/other.py': """
l = [3, 2] values = [3, 2]
def tool(): def tool():
assert l.pop() == 3 assert values.pop() == 3
""", """,
'conftest.py': """ 'conftest.py': """
pytest_plugins = ['pkg.plugin'] pytest_plugins = ['pkg.plugin']
@ -248,7 +248,7 @@ class TestImportHookInstallation(object):
result = testdir.runpytest_subprocess('--assert=rewrite') result = testdir.runpytest_subprocess('--assert=rewrite')
result.stdout.fnmatch_lines(['>*assert a == b*', result.stdout.fnmatch_lines(['>*assert a == b*',
'E*assert 2 == 3*', 'E*assert 2 == 3*',
'>*assert l.pop() == 3*', '>*assert values.pop() == 3*',
'E*AssertionError']) 'E*AssertionError'])
def test_register_assert_rewrite_checks_types(self): def test_register_assert_rewrite_checks_types(self):
@ -263,13 +263,13 @@ class TestBinReprIntegration(object):
def test_pytest_assertrepr_compare_called(self, testdir): def test_pytest_assertrepr_compare_called(self, testdir):
testdir.makeconftest(""" testdir.makeconftest("""
import pytest import pytest
l = [] values = []
def pytest_assertrepr_compare(op, left, right): def pytest_assertrepr_compare(op, left, right):
l.append((op, left, right)) values.append((op, left, right))
@pytest.fixture @pytest.fixture
def list(request): def list(request):
return l return values
""") """)
testdir.makepyfile(""" testdir.makepyfile("""
def test_hello(): def test_hello():

View File

@ -473,8 +473,8 @@ class TestAssertionRewrite(object):
def test_len(self): def test_len(self):
def f(): def f():
l = list(range(10)) values = list(range(10))
assert len(l) == 11 assert len(values) == 11
assert getmsg(f).startswith("""assert 10 == 11 assert getmsg(f).startswith("""assert 10 == 11
+ where 10 = len([""") + where 10 = len([""")

View File

@ -704,9 +704,9 @@ class TestNodekeywords(object):
def test_pass(): pass def test_pass(): pass
def test_fail(): assert 0 def test_fail(): assert 0
""") """)
l = list(modcol.keywords) values = list(modcol.keywords)
assert modcol.name in l assert modcol.name in values
for x in l: for x in values:
assert not x.startswith("_") assert not x.startswith("_")
assert modcol.name in repr(modcol.keywords) assert modcol.name in repr(modcol.keywords)

View File

@ -123,11 +123,11 @@ class TestConfigCmdlineParsing(object):
class TestConfigAPI(object): class TestConfigAPI(object):
def test_config_trace(self, testdir): def test_config_trace(self, testdir):
config = testdir.parseconfig() config = testdir.parseconfig()
l = [] values = []
config.trace.root.setwriter(l.append) config.trace.root.setwriter(values.append)
config.trace("hello") config.trace("hello")
assert len(l) == 1 assert len(values) == 1
assert l[0] == "hello [config]\n" assert values[0] == "hello [config]\n"
def test_config_getoption(self, testdir): def test_config_getoption(self, testdir):
testdir.makeconftest(""" testdir.makeconftest("""
@ -209,10 +209,10 @@ class TestConfigAPI(object):
paths=hello world/sub.py paths=hello world/sub.py
""") """)
config = testdir.parseconfig() config = testdir.parseconfig()
l = config.getini("paths") values = config.getini("paths")
assert len(l) == 2 assert len(values) == 2
assert l[0] == p.dirpath('hello') assert values[0] == p.dirpath('hello')
assert l[1] == p.dirpath('world/sub.py') assert values[1] == p.dirpath('world/sub.py')
pytest.raises(ValueError, config.getini, 'other') pytest.raises(ValueError, config.getini, 'other')
def test_addini_args(self, testdir): def test_addini_args(self, testdir):
@ -226,11 +226,11 @@ class TestConfigAPI(object):
args=123 "123 hello" "this" args=123 "123 hello" "this"
""") """)
config = testdir.parseconfig() config = testdir.parseconfig()
l = config.getini("args") values = config.getini("args")
assert len(l) == 3 assert len(values) == 3
assert l == ["123", "123 hello", "this"] assert values == ["123", "123 hello", "this"]
l = config.getini("a2") values = config.getini("a2")
assert l == list("123") assert values == list("123")
def test_addini_linelist(self, testdir): def test_addini_linelist(self, testdir):
testdir.makeconftest(""" testdir.makeconftest("""
@ -244,11 +244,11 @@ class TestConfigAPI(object):
second line second line
""") """)
config = testdir.parseconfig() config = testdir.parseconfig()
l = config.getini("xy") values = config.getini("xy")
assert len(l) == 2 assert len(values) == 2
assert l == ["123 345", "second line"] assert values == ["123 345", "second line"]
l = config.getini("a2") values = config.getini("a2")
assert l == [] assert values == []
@pytest.mark.parametrize('str_val, bool_val', @pytest.mark.parametrize('str_val, bool_val',
[('True', True), ('no', False), ('no-ini', True)]) [('True', True), ('no', False), ('no-ini', True)])
@ -275,13 +275,13 @@ class TestConfigAPI(object):
xy= 123 xy= 123
""") """)
config = testdir.parseconfig() config = testdir.parseconfig()
l = config.getini("xy") values = config.getini("xy")
assert len(l) == 1 assert len(values) == 1
assert l == ["123"] assert values == ["123"]
config.addinivalue_line("xy", "456") config.addinivalue_line("xy", "456")
l = config.getini("xy") values = config.getini("xy")
assert len(l) == 2 assert len(values) == 2
assert l == ["123", "456"] assert values == ["123", "456"]
def test_addinivalue_line_new(self, testdir): def test_addinivalue_line_new(self, testdir):
testdir.makeconftest(""" testdir.makeconftest("""
@ -291,13 +291,13 @@ class TestConfigAPI(object):
config = testdir.parseconfig() config = testdir.parseconfig()
assert not config.getini("xy") assert not config.getini("xy")
config.addinivalue_line("xy", "456") config.addinivalue_line("xy", "456")
l = config.getini("xy") values = config.getini("xy")
assert len(l) == 1 assert len(values) == 1
assert l == ["456"] assert values == ["456"]
config.addinivalue_line("xy", "123") config.addinivalue_line("xy", "123")
l = config.getini("xy") values = config.getini("xy")
assert len(l) == 2 assert len(values) == 2
assert l == ["456", "123"] assert values == ["456", "123"]
def test_confcutdir_check_isdir(self, testdir): def test_confcutdir_check_isdir(self, testdir):
"""Give an error if --confcutdir is not a valid directory (#2078)""" """Give an error if --confcutdir is not a valid directory (#2078)"""
@ -596,13 +596,13 @@ def test_load_initial_conftest_last_ordering(testdir):
m = My() m = My()
pm.register(m) pm.register(m)
hc = pm.hook.pytest_load_initial_conftests hc = pm.hook.pytest_load_initial_conftests
l = hc._nonwrappers + hc._wrappers values = hc._nonwrappers + hc._wrappers
expected = [ expected = [
"_pytest.config", "_pytest.config",
'test_config', 'test_config',
'_pytest.capture', '_pytest.capture',
] ]
assert [x.function.__module__ for x in l] == expected assert [x.function.__module__ for x in values] == expected
def test_get_plugin_specs_as_list(): def test_get_plugin_specs_as_list():
@ -623,17 +623,17 @@ def test_get_plugin_specs_as_list():
class TestWarning(object): class TestWarning(object):
def test_warn_config(self, testdir): def test_warn_config(self, testdir):
testdir.makeconftest(""" testdir.makeconftest("""
l = [] values = []
def pytest_configure(config): def pytest_configure(config):
config.warn("C1", "hello") config.warn("C1", "hello")
def pytest_logwarning(code, message): def pytest_logwarning(code, message):
if message == "hello" and code == "C1": if message == "hello" and code == "C1":
l.append(1) values.append(1)
""") """)
testdir.makepyfile(""" testdir.makepyfile("""
def test_proper(pytestconfig): def test_proper(pytestconfig):
import conftest import conftest
assert conftest.l == [1] assert conftest.values == [1]
""") """)
reprec = testdir.inline_run() reprec = testdir.inline_run()
reprec.assertoutcome(passed=1) reprec.assertoutcome(passed=1)

View File

@ -87,8 +87,8 @@ def test_doubledash_considered(testdir):
conf.join("conftest.py").ensure() conf.join("conftest.py").ensure()
conftest = PytestPluginManager() conftest = PytestPluginManager()
conftest_setinitial(conftest, [conf.basename, conf.basename]) conftest_setinitial(conftest, [conf.basename, conf.basename])
l = conftest._getconftestmodules(conf) values = conftest._getconftestmodules(conf)
assert len(l) == 1 assert len(values) == 1
def test_issue151_load_all_conftests(testdir): def test_issue151_load_all_conftests(testdir):
@ -130,28 +130,28 @@ def test_conftestcutdir(testdir):
p = testdir.mkdir("x") p = testdir.mkdir("x")
conftest = PytestPluginManager() conftest = PytestPluginManager()
conftest_setinitial(conftest, [testdir.tmpdir], confcutdir=p) conftest_setinitial(conftest, [testdir.tmpdir], confcutdir=p)
l = conftest._getconftestmodules(p) values = conftest._getconftestmodules(p)
assert len(l) == 0 assert len(values) == 0
l = conftest._getconftestmodules(conf.dirpath()) values = conftest._getconftestmodules(conf.dirpath())
assert len(l) == 0 assert len(values) == 0
assert conf not in conftest._conftestpath2mod assert conf not in conftest._conftestpath2mod
# but we can still import a conftest directly # but we can still import a conftest directly
conftest._importconftest(conf) conftest._importconftest(conf)
l = conftest._getconftestmodules(conf.dirpath()) values = conftest._getconftestmodules(conf.dirpath())
assert l[0].__file__.startswith(str(conf)) assert values[0].__file__.startswith(str(conf))
# and all sub paths get updated properly # and all sub paths get updated properly
l = conftest._getconftestmodules(p) values = conftest._getconftestmodules(p)
assert len(l) == 1 assert len(values) == 1
assert l[0].__file__.startswith(str(conf)) assert values[0].__file__.startswith(str(conf))
def test_conftestcutdir_inplace_considered(testdir): def test_conftestcutdir_inplace_considered(testdir):
conf = testdir.makeconftest("") conf = testdir.makeconftest("")
conftest = PytestPluginManager() conftest = PytestPluginManager()
conftest_setinitial(conftest, [conf.dirpath()], confcutdir=conf.dirpath()) conftest_setinitial(conftest, [conf.dirpath()], confcutdir=conf.dirpath())
l = conftest._getconftestmodules(conf.dirpath()) values = conftest._getconftestmodules(conf.dirpath())
assert len(l) == 1 assert len(values) == 1
assert l[0].__file__.startswith(str(conf)) assert values[0].__file__.startswith(str(conf))
@pytest.mark.parametrize("name", 'test tests whatever .dotdir'.split()) @pytest.mark.parametrize("name", 'test tests whatever .dotdir'.split())

View File

@ -468,11 +468,11 @@ class TestFunctional(object):
assert marker.kwargs == {'x': 1, 'y': 2, 'z': 4} assert marker.kwargs == {'x': 1, 'y': 2, 'z': 4}
# test the new __iter__ interface # test the new __iter__ interface
l = list(marker) values = list(marker)
assert len(l) == 3 assert len(values) == 3
assert l[0].args == ("pos0",) assert values[0].args == ("pos0",)
assert l[1].args == () assert values[1].args == ()
assert l[2].args == ("pos1", ) assert values[2].args == ("pos1", )
@pytest.mark.xfail(reason='unfixed') @pytest.mark.xfail(reason='unfixed')
def test_merging_markers_deep(self, testdir): def test_merging_markers_deep(self, testdir):
@ -564,9 +564,9 @@ class TestFunctional(object):
def test_func(): def test_func():
pass pass
""") """)
l = reprec.getfailedcollections() values = reprec.getfailedcollections()
assert len(l) == 1 assert len(values) == 1
assert "TypeError" in str(l[0].longrepr) assert "TypeError" in str(values[0].longrepr)
def test_mark_dynamically_in_funcarg(self, testdir): def test_mark_dynamically_in_funcarg(self, testdir):
testdir.makeconftest(""" testdir.makeconftest("""
@ -575,8 +575,8 @@ class TestFunctional(object):
def arg(request): def arg(request):
request.applymarker(pytest.mark.hello) request.applymarker(pytest.mark.hello)
def pytest_terminal_summary(terminalreporter): def pytest_terminal_summary(terminalreporter):
l = terminalreporter.stats['passed'] values = terminalreporter.stats['passed']
terminalreporter.writer.line("keyword: %s" % l[0].keywords) terminalreporter.writer.line("keyword: %s" % values[0].keywords)
""") """)
testdir.makepyfile(""" testdir.makepyfile("""
def test_func(arg): def test_func(arg):
@ -599,10 +599,10 @@ class TestFunctional(object):
item, = items item, = items
keywords = item.keywords keywords = item.keywords
marker = keywords['hello'] marker = keywords['hello']
l = list(marker) values = list(marker)
assert len(l) == 2 assert len(values) == 2
assert l[0].args == ("pos0",) assert values[0].args == ("pos0",)
assert l[1].args == ("pos1",) assert values[1].args == ("pos1",)
def test_no_marker_match_on_unmarked_names(self, testdir): def test_no_marker_match_on_unmarked_names(self, testdir):
p = testdir.makepyfile(""" p = testdir.makepyfile("""

View File

@ -8,18 +8,18 @@ def setup_module(mod):
def test_nose_setup(testdir): def test_nose_setup(testdir):
p = testdir.makepyfile(""" p = testdir.makepyfile("""
l = [] values = []
from nose.tools import with_setup from nose.tools import with_setup
@with_setup(lambda: l.append(1), lambda: l.append(2)) @with_setup(lambda: values.append(1), lambda: values.append(2))
def test_hello(): def test_hello():
assert l == [1] assert values == [1]
def test_world(): def test_world():
assert l == [1,2] assert values == [1,2]
test_hello.setup = lambda: l.append(1) test_hello.setup = lambda: values.append(1)
test_hello.teardown = lambda: l.append(2) test_hello.teardown = lambda: values.append(2)
""") """)
result = testdir.runpytest(p, '-p', 'nose') result = testdir.runpytest(p, '-p', 'nose')
result.assert_outcomes(passed=2) result.assert_outcomes(passed=2)
@ -27,15 +27,15 @@ def test_nose_setup(testdir):
def test_setup_func_with_setup_decorator(): def test_setup_func_with_setup_decorator():
from _pytest.nose import call_optional from _pytest.nose import call_optional
l = [] values = []
class A(object): class A(object):
@pytest.fixture(autouse=True) @pytest.fixture(autouse=True)
def f(self): def f(self):
l.append(1) values.append(1)
call_optional(A(), "f") call_optional(A(), "f")
assert not l assert not values
def test_setup_func_not_callable(): def test_setup_func_not_callable():
@ -51,24 +51,24 @@ def test_nose_setup_func(testdir):
p = testdir.makepyfile(""" p = testdir.makepyfile("""
from nose.tools import with_setup from nose.tools import with_setup
l = [] values = []
def my_setup(): def my_setup():
a = 1 a = 1
l.append(a) values.append(a)
def my_teardown(): def my_teardown():
b = 2 b = 2
l.append(b) values.append(b)
@with_setup(my_setup, my_teardown) @with_setup(my_setup, my_teardown)
def test_hello(): def test_hello():
print (l) print (values)
assert l == [1] assert values == [1]
def test_world(): def test_world():
print (l) print (values)
assert l == [1,2] assert values == [1,2]
""") """)
result = testdir.runpytest(p, '-p', 'nose') result = testdir.runpytest(p, '-p', 'nose')
@ -79,18 +79,18 @@ def test_nose_setup_func_failure(testdir):
p = testdir.makepyfile(""" p = testdir.makepyfile("""
from nose.tools import with_setup from nose.tools import with_setup
l = [] values = []
my_setup = lambda x: 1 my_setup = lambda x: 1
my_teardown = lambda x: 2 my_teardown = lambda x: 2
@with_setup(my_setup, my_teardown) @with_setup(my_setup, my_teardown)
def test_hello(): def test_hello():
print (l) print (values)
assert l == [1] assert values == [1]
def test_world(): def test_world():
print (l) print (values)
assert l == [1,2] assert values == [1,2]
""") """)
result = testdir.runpytest(p, '-p', 'nose') result = testdir.runpytest(p, '-p', 'nose')
@ -101,13 +101,13 @@ def test_nose_setup_func_failure(testdir):
def test_nose_setup_func_failure_2(testdir): def test_nose_setup_func_failure_2(testdir):
testdir.makepyfile(""" testdir.makepyfile("""
l = [] values = []
my_setup = 1 my_setup = 1
my_teardown = 2 my_teardown = 2
def test_hello(): def test_hello():
assert l == [] assert values == []
test_hello.setup = my_setup test_hello.setup = my_setup
test_hello.teardown = my_teardown test_hello.teardown = my_teardown
@ -121,26 +121,26 @@ def test_nose_setup_partial(testdir):
p = testdir.makepyfile(""" p = testdir.makepyfile("""
from functools import partial from functools import partial
l = [] values = []
def my_setup(x): def my_setup(x):
a = x a = x
l.append(a) values.append(a)
def my_teardown(x): def my_teardown(x):
b = x b = x
l.append(b) values.append(b)
my_setup_partial = partial(my_setup, 1) my_setup_partial = partial(my_setup, 1)
my_teardown_partial = partial(my_teardown, 2) my_teardown_partial = partial(my_teardown, 2)
def test_hello(): def test_hello():
print (l) print (values)
assert l == [1] assert values == [1]
def test_world(): def test_world():
print (l) print (values)
assert l == [1,2] assert values == [1,2]
test_hello.setup = my_setup_partial test_hello.setup = my_setup_partial
test_hello.teardown = my_teardown_partial test_hello.teardown = my_teardown_partial
@ -251,19 +251,19 @@ def test_module_level_setup(testdir):
def test_nose_style_setup_teardown(testdir): def test_nose_style_setup_teardown(testdir):
testdir.makepyfile(""" testdir.makepyfile("""
l = [] values = []
def setup_module(): def setup_module():
l.append(1) values.append(1)
def teardown_module(): def teardown_module():
del l[0] del values[0]
def test_hello(): def test_hello():
assert l == [1] assert values == [1]
def test_world(): def test_world():
assert l == [1] assert values == [1]
""") """)
result = testdir.runpytest('-p', 'nose') result = testdir.runpytest('-p', 'nose')
result.stdout.fnmatch_lines([ result.stdout.fnmatch_lines([

View File

@ -85,23 +85,23 @@ class TestPytestPluginInteractions(object):
def test_configure(self, testdir): def test_configure(self, testdir):
config = testdir.parseconfig() config = testdir.parseconfig()
l = [] values = []
class A(object): class A(object):
def pytest_configure(self, config): def pytest_configure(self, config):
l.append(self) values.append(self)
config.pluginmanager.register(A()) config.pluginmanager.register(A())
assert len(l) == 0 assert len(values) == 0
config._do_configure() config._do_configure()
assert len(l) == 1 assert len(values) == 1
config.pluginmanager.register(A()) # leads to a configured() plugin config.pluginmanager.register(A()) # leads to a configured() plugin
assert len(l) == 2 assert len(values) == 2
assert l[0] != l[1] assert values[0] != values[1]
config._ensure_unconfigure() config._ensure_unconfigure()
config.pluginmanager.register(A()) config.pluginmanager.register(A())
assert len(l) == 2 assert len(values) == 2
def test_hook_tracing(self): def test_hook_tracing(self):
pytestpm = get_config().pluginmanager # fully initialized with plugins pytestpm = get_config().pluginmanager # fully initialized with plugins
@ -116,19 +116,19 @@ class TestPytestPluginInteractions(object):
saveindent.append(pytestpm.trace.root.indent) saveindent.append(pytestpm.trace.root.indent)
raise ValueError() raise ValueError()
l = [] values = []
pytestpm.trace.root.setwriter(l.append) pytestpm.trace.root.setwriter(values.append)
undo = pytestpm.enable_tracing() undo = pytestpm.enable_tracing()
try: try:
indent = pytestpm.trace.root.indent indent = pytestpm.trace.root.indent
p = api1() p = api1()
pytestpm.register(p) pytestpm.register(p)
assert pytestpm.trace.root.indent == indent assert pytestpm.trace.root.indent == indent
assert len(l) >= 2 assert len(values) >= 2
assert 'pytest_plugin_registered' in l[0] assert 'pytest_plugin_registered' in values[0]
assert 'finish' in l[1] assert 'finish' in values[1]
l[:] = [] values[:] = []
with pytest.raises(ValueError): with pytest.raises(ValueError):
pytestpm.register(api2()) pytestpm.register(api2())
assert pytestpm.trace.root.indent == indent assert pytestpm.trace.root.indent == indent
@ -218,12 +218,12 @@ class TestPytestPluginManager(object):
mod = py.std.types.ModuleType("x.y.pytest_hello") mod = py.std.types.ModuleType("x.y.pytest_hello")
pm.register(mod) pm.register(mod)
assert pm.is_registered(mod) assert pm.is_registered(mod)
l = pm.get_plugins() values = pm.get_plugins()
assert mod in l assert mod in values
pytest.raises(ValueError, "pm.register(mod)") pytest.raises(ValueError, "pm.register(mod)")
pytest.raises(ValueError, lambda: pm.register(mod)) pytest.raises(ValueError, lambda: pm.register(mod))
# assert not pm.is_registered(mod2) # assert not pm.is_registered(mod2)
assert pm.get_plugins() == l assert pm.get_plugins() == values
def test_canonical_import(self, monkeypatch): def test_canonical_import(self, monkeypatch):
mod = py.std.types.ModuleType("pytest_xyz") mod = py.std.types.ModuleType("pytest_xyz")
@ -257,8 +257,8 @@ class TestPytestPluginManager(object):
# check that it is not registered twice # check that it is not registered twice
pytestpm.consider_module(mod) pytestpm.consider_module(mod)
l = reprec.getcalls("pytest_plugin_registered") values = reprec.getcalls("pytest_plugin_registered")
assert len(l) == 1 assert len(values) == 1
def test_consider_env_fails_to_import(self, monkeypatch, pytestpm): def test_consider_env_fails_to_import(self, monkeypatch, pytestpm):
monkeypatch.setenv('PYTEST_PLUGINS', 'nonexisting', prepend=",") monkeypatch.setenv('PYTEST_PLUGINS', 'nonexisting', prepend=",")

View File

@ -30,10 +30,10 @@ class TestWarningsRecorderChecker(object):
assert len(rec.list) == 2 assert len(rec.list) == 2
warn = rec.pop() warn = rec.pop()
assert str(warn.message) == "hello" assert str(warn.message) == "hello"
l = rec.list values = rec.list
rec.clear() rec.clear()
assert len(rec.list) == 0 assert len(rec.list) == 0
assert l is rec.list assert values is rec.list
pytest.raises(AssertionError, "rec.pop()") pytest.raises(AssertionError, "rec.pop()")
def test_typechecking(self): def test_typechecking(self):

View File

@ -13,12 +13,12 @@ class TestSetupState(object):
def test_setup(self, testdir): def test_setup(self, testdir):
ss = runner.SetupState() ss = runner.SetupState()
item = testdir.getitem("def test_func(): pass") item = testdir.getitem("def test_func(): pass")
l = [1] values = [1]
ss.prepare(item) ss.prepare(item)
ss.addfinalizer(l.pop, colitem=item) ss.addfinalizer(values.pop, colitem=item)
assert l assert values
ss._pop_and_teardown() ss._pop_and_teardown()
assert not l assert not values
def test_teardown_exact_stack_empty(self, testdir): def test_teardown_exact_stack_empty(self, testdir):
item = testdir.getitem("def test_func(): pass") item = testdir.getitem("def test_func(): pass")

View File

@ -39,20 +39,20 @@ def test_module_and_function_setup(testdir):
def test_module_setup_failure_no_teardown(testdir): def test_module_setup_failure_no_teardown(testdir):
reprec = testdir.inline_runsource(""" reprec = testdir.inline_runsource("""
l = [] values = []
def setup_module(module): def setup_module(module):
l.append(1) values.append(1)
0/0 0/0
def test_nothing(): def test_nothing():
pass pass
def teardown_module(module): def teardown_module(module):
l.append(2) values.append(2)
""") """)
reprec.assertoutcome(failed=1) reprec.assertoutcome(failed=1)
calls = reprec.getcalls("pytest_runtest_setup") calls = reprec.getcalls("pytest_runtest_setup")
assert calls[0].item.module.l == [1] assert calls[0].item.module.values == [1]
def test_setup_function_failure_no_teardown(testdir): def test_setup_function_failure_no_teardown(testdir):

View File

@ -45,9 +45,9 @@ class SessionTests(object):
a = 1 a = 1
""") """)
reprec = testdir.inline_run(tfile) reprec = testdir.inline_run(tfile)
l = reprec.getfailedcollections() values = reprec.getfailedcollections()
assert len(l) == 1 assert len(values) == 1
out = str(l[0].longrepr) out = str(values[0].longrepr)
assert out.find('does_not_work') != -1 assert out.find('does_not_work') != -1
def test_raises_output(self, testdir): def test_raises_output(self, testdir):
@ -75,9 +75,9 @@ class SessionTests(object):
def test_syntax_error_module(self, testdir): def test_syntax_error_module(self, testdir):
reprec = testdir.inline_runsource("this is really not python") reprec = testdir.inline_runsource("this is really not python")
l = reprec.getfailedcollections() values = reprec.getfailedcollections()
assert len(l) == 1 assert len(values) == 1
out = str(l[0].longrepr) out = str(values[0].longrepr)
assert out.find(str('not python')) != -1 assert out.find(str('not python')) != -1
def test_exit_first_problem(self, testdir): def test_exit_first_problem(self, testdir):
@ -144,15 +144,15 @@ class TestNewSession(SessionTests):
def test_order_of_execution(self, testdir): def test_order_of_execution(self, testdir):
reprec = testdir.inline_runsource(""" reprec = testdir.inline_runsource("""
l = [] values = []
def test_1(): def test_1():
l.append(1) values.append(1)
def test_2(): def test_2():
l.append(2) values.append(2)
def test_3(): def test_3():
assert l == [1,2] assert values == [1,2]
class Testmygroup(object): class Testmygroup(object):
reslist = l reslist = values
def test_1(self): def test_1(self):
self.reslist.append(1) self.reslist.append(1)
def test_2(self): def test_2(self):
@ -242,13 +242,13 @@ def test_exclude(testdir):
def test_sessionfinish_with_start(testdir): def test_sessionfinish_with_start(testdir):
testdir.makeconftest(""" testdir.makeconftest("""
import os import os
l = [] values = []
def pytest_sessionstart(): def pytest_sessionstart():
l.append(os.getcwd()) values.append(os.getcwd())
os.chdir("..") os.chdir("..")
def pytest_sessionfinish(): def pytest_sessionfinish():
assert l[0] == os.getcwd() assert values[0] == os.getcwd()
""") """)
res = testdir.runpytest("--collect-only") res = testdir.runpytest("--collect-only")

View File

@ -685,9 +685,9 @@ def test_skip_reasons_folding():
ev3.longrepr = longrepr ev3.longrepr = longrepr
ev3.skipped = True ev3.skipped = True
l = folded_skips([ev1, ev2, ev3]) values = folded_skips([ev1, ev2, ev3])
assert len(l) == 1 assert len(values) == 1
num, fspath, lineno, reason = l[0] num, fspath, lineno, reason = values[0]
assert num == 3 assert num == 3
assert fspath == path assert fspath == path
assert lineno == lineno assert lineno == lineno

View File

@ -24,12 +24,12 @@ class Option(object):
@property @property
def args(self): def args(self):
l = [] values = []
if self.verbose: if self.verbose:
l.append('-v') values.append('-v')
if self.fulltrace: if self.fulltrace:
l.append('--fulltrace') values.append('--fulltrace')
return l return values
def pytest_generate_tests(metafunc): def pytest_generate_tests(metafunc):

View File

@ -73,19 +73,19 @@ def test_setup(testdir):
def test_setUpModule(testdir): def test_setUpModule(testdir):
testpath = testdir.makepyfile(""" testpath = testdir.makepyfile("""
l = [] values = []
def setUpModule(): def setUpModule():
l.append(1) values.append(1)
def tearDownModule(): def tearDownModule():
del l[0] del values[0]
def test_hello(): def test_hello():
assert l == [1] assert values == [1]
def test_world(): def test_world():
assert l == [1] assert values == [1]
""") """)
result = testdir.runpytest(testpath) result = testdir.runpytest(testpath)
result.stdout.fnmatch_lines([ result.stdout.fnmatch_lines([
@ -95,13 +95,13 @@ def test_setUpModule(testdir):
def test_setUpModule_failing_no_teardown(testdir): def test_setUpModule_failing_no_teardown(testdir):
testpath = testdir.makepyfile(""" testpath = testdir.makepyfile("""
l = [] values = []
def setUpModule(): def setUpModule():
0/0 0/0
def tearDownModule(): def tearDownModule():
l.append(1) values.append(1)
def test_hello(): def test_hello():
pass pass
@ -109,7 +109,7 @@ def test_setUpModule_failing_no_teardown(testdir):
reprec = testdir.inline_run(testpath) reprec = testdir.inline_run(testpath)
reprec.assertoutcome(passed=0, failed=1) reprec.assertoutcome(passed=0, failed=1)
call = reprec.getcalls("pytest_runtest_setup")[0] call = reprec.getcalls("pytest_runtest_setup")[0]
assert not call.item.module.l assert not call.item.module.values
def test_new_instances(testdir): def test_new_instances(testdir):
@ -129,14 +129,14 @@ def test_teardown(testdir):
testpath = testdir.makepyfile(""" testpath = testdir.makepyfile("""
import unittest import unittest
class MyTestCase(unittest.TestCase): class MyTestCase(unittest.TestCase):
l = [] values = []
def test_one(self): def test_one(self):
pass pass
def tearDown(self): def tearDown(self):
self.l.append(None) self.values.append(None)
class Second(unittest.TestCase): class Second(unittest.TestCase):
def test_check(self): def test_check(self):
self.assertEqual(MyTestCase.l, [None]) self.assertEqual(MyTestCase.values, [None])
""") """)
reprec = testdir.inline_run(testpath) reprec = testdir.inline_run(testpath)
passed, skipped, failed = reprec.countoutcomes() passed, skipped, failed = reprec.countoutcomes()

View File

@ -144,6 +144,8 @@ def test_unicode(testdir, pyfile_with_warnings):
@pytest.mark.skipif(sys.version_info >= (3, 0), @pytest.mark.skipif(sys.version_info >= (3, 0),
reason='warnings message is broken as it is not str instance') reason='warnings message is broken as it is not str instance')
def test_py2_unicode(testdir, pyfile_with_warnings): def test_py2_unicode(testdir, pyfile_with_warnings):
if getattr(sys, "pypy_version_info", ())[:2] == (5, 9) and sys.platform.startswith('win'):
pytest.xfail("fails with unicode error on PyPy2 5.9 and Windows (#2905)")
testdir.makepyfile(''' testdir.makepyfile('''
# -*- coding: utf8 -*- # -*- coding: utf8 -*-
import warnings import warnings

View File

@ -218,8 +218,3 @@ filterwarnings =
[flake8] [flake8]
max-line-length = 120 max-line-length = 120
ignore=
# do not use bare except'
E722
# ambiguous variable name 'l'
E741