diff --git a/setup/test.py b/setup/test.py index 56ade73453..634b26f344 100644 --- a/setup/test.py +++ b/setup/test.py @@ -78,6 +78,8 @@ class Test(Command): def run(self, opts): from calibre.utils.run_tests import run_cli, filter_tests_by_name + from calibre.gui2 import ensure_app + ensure_app() tests = find_tests(which_tests=frozenset(opts.test_module)) if opts.test_name: tests = filter_tests_by_name(tests, *opts.test_name) diff --git a/src/calibre/test_build.py b/src/calibre/test_build.py index 0e7613bb8b..5ec643a683 100644 --- a/src/calibre/test_build.py +++ b/src/calibre/test_build.py @@ -101,9 +101,6 @@ class BuildTest(unittest.TestCase): conn.close() def test_qt(self): - # Must be run before QApplication is constructed - # Test that the image formats are available without a QApplication being - # constructed from PyQt5.Qt import QImageReader, QNetworkAccessManager, QFontDatabase from calibre.utils.img import image_from_data, image_to_data, test fmts = set(map(unicode, QImageReader.supportedImageFormats())) diff --git a/src/calibre/utils/img.py b/src/calibre/utils/img.py index bcd9f5abc2..9246080894 100644 --- a/src/calibre/utils/img.py +++ b/src/calibre/utils/img.py @@ -8,19 +8,12 @@ import os, subprocess, errno, shutil, tempfile, sys from io import BytesIO from threading import Thread -from PyQt5.Qt import QImage, QByteArray, QBuffer, Qt, QImageReader, QColor, QImageWriter, QTransform, QCoreApplication - +from PyQt5.Qt import QImage, QByteArray, QBuffer, Qt, QImageReader, QColor, QImageWriter, QTransform from calibre import fit_image, force_unicode from calibre.constants import iswindows, plugins, get_version from calibre.utils.config_base import tweaks from calibre.utils.filenames import atomic_rename -# Ensure that Qt can load the imageformat plugins - -if QCoreApplication.instance() is None: - # We need a QCoreApplication() in order to load imageformat plugins - _core_app = QCoreApplication([]) - # Utilities {{{ imageops, imageops_err = plugins['imageops'] if imageops is None: