From 270bc4fc6031d9ab67c62b55de3292167b041f57 Mon Sep 17 00:00:00 2001 From: Hugo Date: Sun, 19 Apr 2020 13:59:40 +0300 Subject: [PATCH 1/2] Don't show own deprecation warning in test logs --- Tests/test_imagefile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/test_imagefile.py b/Tests/test_imagefile.py index 649b0ac9b..7719c7c71 100644 --- a/Tests/test_imagefile.py +++ b/Tests/test_imagefile.py @@ -95,7 +95,7 @@ class TestImageFile: def test_raise_ioerror(self): with pytest.raises(IOError): - with pytest.raises(DeprecationWarning): + with pytest.warns(DeprecationWarning): ImageFile.raise_ioerror(1) def test_raise_oserror(self): From a0641b87c27bf3b24b531e393b8d2621f351b26d Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Mon, 20 Apr 2020 19:27:09 +1000 Subject: [PATCH 2/2] Assert that warning is raised --- Tests/test_imagefile.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Tests/test_imagefile.py b/Tests/test_imagefile.py index 7719c7c71..6964d3e00 100644 --- a/Tests/test_imagefile.py +++ b/Tests/test_imagefile.py @@ -95,8 +95,9 @@ class TestImageFile: def test_raise_ioerror(self): with pytest.raises(IOError): - with pytest.warns(DeprecationWarning): + with pytest.warns(DeprecationWarning) as record: ImageFile.raise_ioerror(1) + assert len(record) == 1 def test_raise_oserror(self): with pytest.raises(OSError):