Merge pull request #2563 from pv/yield-warn-spam

Make YIELD_TEST warning less spammy
This commit is contained in:
Ronny Pfannschmidt 2017-07-13 10:45:46 +02:00 committed by GitHub
commit 81cec9f5e3
3 changed files with 6 additions and 1 deletions

View File

@ -615,7 +615,7 @@ 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))
self.config.warn('C1', deprecated.YIELD_TESTS, fslocation=self.fspath)
self.warn('C1', deprecated.YIELD_TESTS)
return l
def getcallargs(self, obj):

1
changelog/2562.trivial Normal file
View File

@ -0,0 +1 @@
Emit yield test warning only once per generator

View File

@ -9,12 +9,16 @@ def test_yield_tests_deprecation(testdir):
def test_gen():
yield "m1", func1, 15, 3*5
yield "m2", func1, 42, 6*7
def test_gen2():
for k in range(10):
yield func1, 1, 1
""")
result = testdir.runpytest('-ra')
result.stdout.fnmatch_lines([
'*yield tests are deprecated, and scheduled to be removed in pytest 4.0*',
'*2 passed*',
])
assert result.stdout.str().count('yield tests are deprecated') == 2
def test_funcarg_prefix_deprecation(testdir):