From e4a21b11d5818afbe704bfa57f48d961e1a0b7a4 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Wed, 9 Jan 2019 18:58:51 -0200 Subject: [PATCH] Change test_warningschecker_twice to a unittest --- testing/test_warnings.py | 28 +++++++--------------------- 1 file changed, 7 insertions(+), 21 deletions(-) diff --git a/testing/test_warnings.py b/testing/test_warnings.py index 45e196149..e8075b617 100644 --- a/testing/test_warnings.py +++ b/testing/test_warnings.py @@ -2,6 +2,7 @@ from __future__ import unicode_literals import sys +import warnings import six @@ -685,25 +686,10 @@ class TestAssertionWarnings: result.stdout.fnmatch_lines(["*1 failed in*"]) -def test_warningschecker_twice(testdir): +def test_warnings_checker_twice(): """Issue #4617""" - - testdir.makepyfile( - """ - import pytest - import warnings - - @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 *"]) + expectation = pytest.warns(UserWarning) + with expectation: + warnings.warn("Message A", UserWarning) + with expectation: + warnings.warn("Message B", UserWarning)