From 3c07072bfd3580bcd1b7334f77d2352cb8a9814d Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Mon, 13 Mar 2017 19:52:35 -0300 Subject: [PATCH] Fix test_recwarn in Python 3.6 No longer test for implementation details of recwarn since warnings.catch_warnings has changed significantly in 3.6. --- testing/test_recwarn.py | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/testing/test_recwarn.py b/testing/test_recwarn.py index c5244411c..1269af431 100644 --- a/testing/test_recwarn.py +++ b/testing/test_recwarn.py @@ -8,25 +8,19 @@ from _pytest.recwarn import WarningsRecorder def test_recwarn_functional(testdir): reprec = testdir.inline_runsource(""" import warnings - oldwarn = warnings.showwarning def test_method(recwarn): - assert warnings.showwarning != oldwarn warnings.warn("hello") warn = recwarn.pop() assert isinstance(warn.message, UserWarning) - def test_finalized(): - assert warnings.showwarning == oldwarn """) res = reprec.countoutcomes() - assert tuple(res) == (2, 0, 0), res + assert tuple(res) == (1, 0, 0), res class TestWarningsRecorderChecker(object): - def test_recording(self, recwarn): - showwarning = py.std.warnings.showwarning + def test_recording(self): rec = WarningsRecorder() with rec: - assert py.std.warnings.showwarning != showwarning assert not rec.list py.std.warnings.warn_explicit("hello", UserWarning, "xyz", 13) assert len(rec.list) == 1 @@ -40,8 +34,6 @@ class TestWarningsRecorderChecker(object): assert l is rec.list pytest.raises(AssertionError, "rec.pop()") - assert showwarning == py.std.warnings.showwarning - def test_typechecking(self): from _pytest.recwarn import WarningsChecker with pytest.raises(TypeError):