Skip to content

Commit

Permalink
Fix test failures on EDM and Python 3.8 (#1090)
Browse files Browse the repository at this point in the history
* Fix test failures on EDM and Python 3.8

These are fairly basic fixes - just skip when in an incompatible environment
- but issues have been opened for more complete fixes.

* Make pillow optional for tests.

* Update skip comment based on PR suggestions
  • Loading branch information
corranwebster authored Jan 28, 2022
1 parent 3fdd2cb commit ab3f2d7
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
14 changes: 12 additions & 2 deletions pyface/tests/test_pil_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@


import os
import logging
import unittest

# importlib.resources is new in Python 3.7, and importlib.resources.files is
Expand All @@ -20,13 +21,22 @@
except ImportError:
from importlib_resources import files

from PIL import Image
from pyface.util._optional_dependencies import optional_import

from ..pil_image import PILImage
Image = None

with optional_import(
"pillow",
msg="PILImage not available due to missing pillow.",
logger=logging.getLogger(__name__)):

from PIL import Image
from ..pil_image import PILImage

IMAGE_PATH = os.fspath(files("pyface.tests") / "images" / "core.png")


@unittest.skipIf(Image is None, "Pillow not available")
class TestPILImage(unittest.TestCase):

def setUp(self):
Expand Down
6 changes: 5 additions & 1 deletion pyface/ui/qt4/tests/test_qt_imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#
# Thanks for using Enthought open source!

import sys
import unittest
import warnings

Expand All @@ -21,10 +22,13 @@ def test_imports(self):
import pyface.qt.QtOpenGL # noqa: F401
import pyface.qt.QtSvg # noqa: F401
import pyface.qt.QtTest # noqa: F401
import pyface.qt.QtWebKit # noqa: F401
import pyface.qt.QtMultimedia # noqa: F401
import pyface.qt.QtMultimediaWidgets # noqa: F401

@unittest.skipIf(sys.version_info > (3, 6), "WebKit is not available")
def test_import_web_kit(self):
import pyface.qt.QtWebKit # noqa: F401

def test_import_QtScript(self):
# QtScript is not supported on PyQt5/PySide2 and
# this import will raise a deprecation warning.
Expand Down
5 changes: 5 additions & 0 deletions pyface/ui/qt4/workbench/tests/test_workbench_window_layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
# Thanks for using Enthought open source!


import sys
import unittest
from unittest import mock

Expand All @@ -19,9 +20,13 @@


class TestWorkbenchWindowLayout(unittest.TestCase):

@unittest.skipIf(sys.version_info == (3, 8), "Can't mock SplitTabWidget")
def test_change_of_active_qt_editor(self):
# Test error condition for enthought/mayavi#321

# This doesn't work on Python 3.8 because of some incompatibility
# between unittest.mock.Mock and Qt, I think
mock_split_tab_widget = mock.Mock(spec=SplitTabWidget)

layout = WorkbenchWindowLayout(_qt4_editor_area=mock_split_tab_widget)
Expand Down

0 comments on commit ab3f2d7

Please sign in to comment.