mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-26 01:04:29 +03:00
Catch DeprecationWarning from initial import
This commit is contained in:
parent
6e1227765e
commit
38b5255f58
|
@ -1,13 +1,16 @@
|
||||||
from .helper import PillowTestCase, hopper
|
from .helper import PillowTestCase, hopper
|
||||||
|
|
||||||
from PIL import ImageQt
|
import warnings
|
||||||
|
|
||||||
try:
|
deprecated = False
|
||||||
# Python 3
|
with warnings.catch_warnings():
|
||||||
from importlib import reload
|
warnings.filterwarnings("error", category=DeprecationWarning)
|
||||||
except ImportError:
|
try:
|
||||||
# Python 2.7
|
from PIL import ImageQt
|
||||||
pass
|
except DeprecationWarning:
|
||||||
|
deprecated = True
|
||||||
|
warnings.filterwarnings("ignore", category=DeprecationWarning)
|
||||||
|
from PIL import ImageQt
|
||||||
|
|
||||||
if ImageQt.qt_is_installed:
|
if ImageQt.qt_is_installed:
|
||||||
from PIL.ImageQt import qRgba
|
from PIL.ImageQt import qRgba
|
||||||
|
@ -86,5 +89,4 @@ class TestImageQt(PillowQtTestCase, PillowTestCase):
|
||||||
ImageQt.ImageQt(hopper(mode))
|
ImageQt.ImageQt(hopper(mode))
|
||||||
|
|
||||||
def test_deprecated(self):
|
def test_deprecated(self):
|
||||||
expected = DeprecationWarning if ImageQt.qt_version in ["4", "side"] else None
|
self.assertEqual(ImageQt.qt_version in ["4", "side"], deprecated)
|
||||||
self.assert_warning(expected, reload, ImageQt)
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user