Skip to content

Commit

Permalink
Make EventLoopHelper expect an IGUI instance (#953)
Browse files Browse the repository at this point in the history
* add a failing test

* make gui trait an Instance(IGUI)

* Update pyface/ui/qt4/util/tests/test_event_loop_helper.py

Co-authored-by: Poruri Sai Rahul <rporuri@enthought.com>

Co-authored-by: Poruri Sai Rahul <rporuri@enthought.com>
  • Loading branch information
aaronayres35 and Poruri Sai Rahul authored Jun 17, 2021
1 parent 87c54c8 commit b4152da
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pyface/ui/qt4/util/event_loop_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import contextlib
import threading

from pyface.gui import GUI
from pyface.i_gui import IGUI
from pyface.qt import QtCore, QtGui
from traits.api import HasStrictTraits, Instance

Expand All @@ -39,7 +39,7 @@ class EventLoopHelper(HasStrictTraits):

qt_app = Instance(QtGui.QApplication)

gui = Instance(GUI)
gui = Instance(IGUI)

def event_loop_with_timeout(self, repeat=2, timeout=10.0):
"""Helper function to send all posted events to the event queue and
Expand Down
28 changes: 28 additions & 0 deletions pyface/ui/qt4/util/tests/test_event_loop_helper.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Copyright (c) 2005-2021, Enthought Inc.
# 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!
import unittest

from traits.api import HasTraits, provides

from pyface.i_gui import IGUI
from pyface.ui.qt4.util.event_loop_helper import EventLoopHelper


@provides(IGUI)
class DummyGUI(HasTraits):
pass


class TestEventLoopHelper(unittest.TestCase):

def test_gui_trait_expects_IGUI_interface(self):
# Trivial test where we simply set the trait
# and the test passes because no errors are raised.
event_loop_helper = EventLoopHelper()
event_loop_helper.gui = DummyGUI()

0 comments on commit b4152da

Please sign in to comment.