parent
6f68dfcc47
commit
5506dc700c
|
@ -185,7 +185,8 @@
|
|||
Before, you only got exceptions later from ``argparse`` library,
|
||||
giving no clue about the actual reason for double-added options.
|
||||
|
||||
*
|
||||
* ``yield``-based tests are considered deprecated and will be removed in pytest-4.0.
|
||||
Thanks `@nicoddemus`_ for the PR.
|
||||
|
||||
*
|
||||
|
||||
|
|
|
@ -589,6 +589,8 @@ class Generator(FunctionMixin, PyCollector):
|
|||
raise ValueError("%r generated tests with non-unique name %r" %(self, name))
|
||||
seen[name] = True
|
||||
l.append(self.Function(name, self, args=args, callobj=call))
|
||||
msg = 'yield tests are deprecated, and scheduled to be removed in pytest 4.0'
|
||||
self.config.warn('C1', msg, fslocation=self.fspath)
|
||||
return l
|
||||
|
||||
def getcallargs(self, obj):
|
||||
|
@ -611,8 +613,6 @@ def hasinit(obj):
|
|||
return True
|
||||
|
||||
|
||||
|
||||
|
||||
class CallSpec2(object):
|
||||
def __init__(self, metafunc):
|
||||
self.metafunc = metafunc
|
||||
|
|
|
@ -762,3 +762,18 @@ class TestDurationWithFixture:
|
|||
* setup *test_1*
|
||||
* call *test_1*
|
||||
""")
|
||||
|
||||
|
||||
def test_yield_tests_deprecation(testdir):
|
||||
testdir.makepyfile("""
|
||||
def func1(arg, arg2):
|
||||
assert arg == arg2
|
||||
def test_gen():
|
||||
yield "m1", func1, 15, 3*5
|
||||
yield "m2", func1, 42, 6*7
|
||||
""")
|
||||
result = testdir.runpytest('-ra')
|
||||
result.stdout.fnmatch_lines([
|
||||
'*yield tests are deprecated, and scheduled to be removed in pytest 4.0*',
|
||||
'*2 passed*',
|
||||
])
|
||||
|
|
|
@ -285,13 +285,14 @@ class TestSourceParsingAndCompiling:
|
|||
#print "block", str(block)
|
||||
assert str(stmt).strip().startswith('assert')
|
||||
|
||||
def test_compilefuncs_and_path_sanity(self):
|
||||
@pytest.mark.parametrize('name', ['', None, 'my'])
|
||||
def test_compilefuncs_and_path_sanity(self, name):
|
||||
def check(comp, name):
|
||||
co = comp(self.source, name)
|
||||
if not name:
|
||||
expected = "codegen %s:%d>" %(mypath, mylineno+2+1)
|
||||
expected = "codegen %s:%d>" %(mypath, mylineno+2+2)
|
||||
else:
|
||||
expected = "codegen %r %s:%d>" % (name, mypath, mylineno+2+1)
|
||||
expected = "codegen %r %s:%d>" % (name, mypath, mylineno+2+2)
|
||||
fn = co.co_filename
|
||||
assert fn.endswith(expected)
|
||||
|
||||
|
@ -300,8 +301,7 @@ class TestSourceParsingAndCompiling:
|
|||
mypath = mycode.path
|
||||
|
||||
for comp in _pytest._code.compile, _pytest._code.Source.compile:
|
||||
for name in '', None, 'my':
|
||||
yield check, comp, name
|
||||
check(comp, name)
|
||||
|
||||
def test_offsetless_synerr(self):
|
||||
pytest.raises(SyntaxError, _pytest._code.compile, "lambda a,a: 0", mode='eval')
|
||||
|
|
Loading…
Reference in New Issue