mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-08-25 22:54:46 +03:00
Only create QGuiApplication once for the test class, not every test case
This commit is contained in:
parent
6b80aa9569
commit
d3b8ac0cc0
|
@ -1,4 +1,4 @@
|
||||||
from .helper import PillowTestCase, hopper
|
from .helper import PillowTestCase, hopper, unittest
|
||||||
|
|
||||||
from PIL import ImageQt
|
from PIL import ImageQt
|
||||||
|
|
||||||
|
@ -6,26 +6,22 @@ from PIL import ImageQt
|
||||||
if ImageQt.qt_is_installed:
|
if ImageQt.qt_is_installed:
|
||||||
from PIL.ImageQt import qRgba
|
from PIL.ImageQt import qRgba
|
||||||
|
|
||||||
def skip_if_qt_is_not_installed(_):
|
|
||||||
pass
|
|
||||||
else:
|
|
||||||
def skip_if_qt_is_not_installed(test_case):
|
|
||||||
test_case.skipTest('Qt bindings are not installed')
|
|
||||||
|
|
||||||
|
|
||||||
class PillowQtTestCase(object):
|
class PillowQtTestCase(object):
|
||||||
|
@classmethod
|
||||||
def setUp(self):
|
def setUpClass(cls):
|
||||||
skip_if_qt_is_not_installed(self)
|
if not ImageQt.qt_is_installed:
|
||||||
|
raise unittest.SkipTest('Qt bindings are not installed')
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class PillowQPixmapTestCase(PillowQtTestCase):
|
class PillowQPixmapTestCase(PillowQtTestCase):
|
||||||
|
@classmethod
|
||||||
|
def setUpClass(cls):
|
||||||
|
super(PillowQPixmapTestCase, cls).setUpClass()
|
||||||
|
|
||||||
def setUp(self):
|
|
||||||
PillowQtTestCase.setUp(self)
|
|
||||||
try:
|
try:
|
||||||
if ImageQt.qt_version == '5':
|
if ImageQt.qt_version == '5':
|
||||||
from PyQt5.QtGui import QGuiApplication
|
from PyQt5.QtGui import QGuiApplication
|
||||||
|
@ -36,9 +32,9 @@ class PillowQPixmapTestCase(PillowQtTestCase):
|
||||||
elif ImageQt.qt_version == 'side2':
|
elif ImageQt.qt_version == 'side2':
|
||||||
from PySide2.QtGui import QGuiApplication
|
from PySide2.QtGui import QGuiApplication
|
||||||
except ImportError:
|
except ImportError:
|
||||||
self.skipTest('QGuiApplication not installed')
|
raise unittest.SkipTest('QGuiApplication not installed')
|
||||||
|
|
||||||
self.app = QGuiApplication([])
|
cls.app = QGuiApplication([])
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
PillowQtTestCase.tearDown(self)
|
PillowQtTestCase.tearDown(self)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user