Skip to content

Commit 2359663

Browse files
authored
Merge pull request #4622 from nicoddemus/warningschecker-unittest
Change test_warningschecker_twice to a unittest
2 parents bace285 + e4a21b1 commit 2359663

File tree

1 file changed

+7
-21
lines changed

1 file changed

+7
-21
lines changed

testing/test_warnings.py

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from __future__ import unicode_literals
33

44
import sys
5+
import warnings
56

67
import six
78

@@ -685,25 +686,10 @@ def test_false_function_no_warn(self, testdir):
685686
result.stdout.fnmatch_lines(["*1 failed in*"])
686687

687688

688-
def test_warningschecker_twice(testdir):
689+
def test_warnings_checker_twice():
689690
"""Issue #4617"""
690-
691-
testdir.makepyfile(
692-
"""
693-
import pytest
694-
import warnings
695-
696-
@pytest.mark.parametrize("other", [1, 2])
697-
@pytest.mark.parametrize("expectation", [
698-
pytest.warns(DeprecationWarning,
699-
match="Message A"),
700-
pytest.warns(DeprecationWarning,
701-
match="Message A"),
702-
])
703-
def test_parametrized_warnings(other, expectation):
704-
with expectation:
705-
warnings.warn("Message A", DeprecationWarning)
706-
"""
707-
)
708-
result = testdir.runpytest()
709-
result.stdout.fnmatch_lines(["* 4 passed in *"])
691+
expectation = pytest.warns(UserWarning)
692+
with expectation:
693+
warnings.warn("Message A", UserWarning)
694+
with expectation:
695+
warnings.warn("Message B", UserWarning)

0 commit comments

Comments
 (0)