Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make pygments optional for pyface.api #796

Merged
merged 4 commits into from
Nov 12, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions pyface/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,17 @@
from .key_pressed_event import KeyPressedEvent
from .message_dialog import error, information, warning, MessageDialog
from .progress_dialog import ProgressDialog
from .python_editor import PythonEditor
from .python_shell import PythonShell

try:
import pygments
except ImportError:
# pygments is a runtime dependency for PythonEditor and PythonShell in Qt.
pass
else:
del pygments
from .python_editor import PythonEditor
from .python_shell import PythonShell

from .sorter import Sorter
from .single_choice_dialog import choose_one, SingleChoiceDialog
from .splash_screen import SplashScreen
Expand Down
21 changes: 21 additions & 0 deletions pyface/tests/test_api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# (C) Copyright 2005-2020 Enthought, Inc., Austin, TX
# All rights reserved.
#
# This software is provided without warranty under the terms of the BSD
# license included in LICENSE.txt and may be redistributed only under
# the conditions described in the aforementioned license. The license
# is also available online at http://www.enthought.com/licenses/BSD.txt
#
# Thanks for using Enthought open source!

""" Test for pyface.api """

import unittest


class TestApi(unittest.TestCase):

def test_api_importable(self):
# make sure api is importable with the most minimal
# required dependencies, including in the absence of toolkit backends.
from pyface import api # noqa: F401
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I verified this test failed when I have an environment with Qt but no pygments. Then the test passes after I made the change in api.py.

Ideally our CI matrix should cover more minimal setups...