Skip to content

Commit 81cec9f

Browse files
Merge pull request #2563 from pv/yield-warn-spam
Make YIELD_TEST warning less spammy
2 parents f16c3b9 + 8a7d98f commit 81cec9f

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

_pytest/python.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -615,7 +615,7 @@ def collect(self):
615615
raise ValueError("%r generated tests with non-unique name %r" %(self, name))
616616
seen[name] = True
617617
l.append(self.Function(name, self, args=args, callobj=call))
618-
self.config.warn('C1', deprecated.YIELD_TESTS, fslocation=self.fspath)
618+
self.warn('C1', deprecated.YIELD_TESTS)
619619
return l
620620

621621
def getcallargs(self, obj):

changelog/2562.trivial

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Emit yield test warning only once per generator

testing/deprecated_test.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,16 @@ def func1(arg, arg2):
99
def test_gen():
1010
yield "m1", func1, 15, 3*5
1111
yield "m2", func1, 42, 6*7
12+
def test_gen2():
13+
for k in range(10):
14+
yield func1, 1, 1
1215
""")
1316
result = testdir.runpytest('-ra')
1417
result.stdout.fnmatch_lines([
1518
'*yield tests are deprecated, and scheduled to be removed in pytest 4.0*',
1619
'*2 passed*',
1720
])
21+
assert result.stdout.str().count('yield tests are deprecated') == 2
1822

1923

2024
def test_funcarg_prefix_deprecation(testdir):

0 commit comments

Comments
 (0)