Merge pull request #4622 from nicoddemus/warningschecker-unittest

Change test_warningschecker_twice to a unittest
This commit is contained in:
Bruno Oliveira 2019-01-10 06:04:25 -02:00 committed by GitHub
commit 2359663437
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 21 deletions

View File

@ -2,6 +2,7 @@
from __future__ import unicode_literals from __future__ import unicode_literals
import sys import sys
import warnings
import six import six
@ -685,25 +686,10 @@ class TestAssertionWarnings:
result.stdout.fnmatch_lines(["*1 failed in*"]) result.stdout.fnmatch_lines(["*1 failed in*"])
def test_warningschecker_twice(testdir): def test_warnings_checker_twice():
"""Issue #4617""" """Issue #4617"""
expectation = pytest.warns(UserWarning)
testdir.makepyfile( with expectation:
""" warnings.warn("Message A", UserWarning)
import pytest with expectation:
import warnings warnings.warn("Message B", UserWarning)
@pytest.mark.parametrize("other", [1, 2])
@pytest.mark.parametrize("expectation", [
pytest.warns(DeprecationWarning,
match="Message A"),
pytest.warns(DeprecationWarning,
match="Message A"),
])
def test_parametrized_warnings(other, expectation):
with expectation:
warnings.warn("Message A", DeprecationWarning)
"""
)
result = testdir.runpytest()
result.stdout.fnmatch_lines(["* 4 passed in *"])