From 9569428247ce463bba6e688b15fefdda07c6d20d Mon Sep 17 00:00:00 2001 From: Sai Rahul Poruri Date: Fri, 28 Aug 2020 12:08:11 +0100 Subject: [PATCH 1/5] TST : Test that a TraitError is raised because the TasksApplication expects it's gui trait to be an instance of GUI object and not an object that supports the IGUI interface modified: envisage/ui/tasks/tests/test_tasks_application.py --- envisage/ui/tasks/tests/test_tasks_application.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/envisage/ui/tasks/tests/test_tasks_application.py b/envisage/ui/tasks/tests/test_tasks_application.py index 2f40c47ac..f9a8e76e9 100644 --- a/envisage/ui/tasks/tests/test_tasks_application.py +++ b/envisage/ui/tasks/tests/test_tasks_application.py @@ -18,6 +18,8 @@ from envisage.ui.tasks.api import TasksApplication from envisage.ui.tasks.tasks_application import DEFAULT_STATE_FILENAME +from pyface.i_gui import IGUI +from traits.api import HasTraits, provides, TraitError requires_gui = unittest.skipIf( os.environ.get("ETS_TOOLKIT", "none") in {"null", "none"}, @@ -25,6 +27,11 @@ ) +@provides(IGUI) +class DummyGUI(HasTraits): + pass + + @requires_gui class TestTasksApplication(unittest.TestCase): def setUp(self): @@ -119,3 +126,8 @@ def test_layout_load_pickle_protocol_3(self): state = app._state self.assertEqual(state.previous_window_layouts[0].size, (492, 743)) + + def test_gui_needs_GUI_instance(self): + with self.assertRaises(TraitError): + app = TasksApplication() + app.gui = DummyGUI() From 081a27c391e74ff9579633e02911b9d4be878e9c Mon Sep 17 00:00:00 2001 From: Sai Rahul Poruri Date: Fri, 28 Aug 2020 12:43:24 +0100 Subject: [PATCH 2/5] FIX : Make TasksApplication.gui use Supports IGUI Not Instance GUI modified: envisage/ui/tasks/tasks_application.py modified: envisage/ui/tasks/tests/test_tasks_application.py --- envisage/ui/tasks/tasks_application.py | 3 ++- envisage/ui/tasks/tests/test_tasks_application.py | 9 +++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/envisage/ui/tasks/tasks_application.py b/envisage/ui/tasks/tasks_application.py index d204a98c7..034c6d966 100644 --- a/envisage/ui/tasks/tasks_application.py +++ b/envisage/ui/tasks/tasks_application.py @@ -24,6 +24,7 @@ Int, List, Str, + Supports, Vetoable, ) from traits.etsconfig.api import ETSConfig @@ -60,7 +61,7 @@ class TasksApplication(Application): active_window = Instance("envisage.ui.tasks.task_window.TaskWindow") # The Pyface GUI for the application. - gui = Instance("pyface.gui.GUI") + gui = Supports("pyface.i_gui.IGUI") # Icon for the whole application. Will be used to override all taskWindows # icons to have the same. diff --git a/envisage/ui/tasks/tests/test_tasks_application.py b/envisage/ui/tasks/tests/test_tasks_application.py index f9a8e76e9..a9c59cffe 100644 --- a/envisage/ui/tasks/tests/test_tasks_application.py +++ b/envisage/ui/tasks/tests/test_tasks_application.py @@ -32,7 +32,7 @@ class DummyGUI(HasTraits): pass -@requires_gui + class TestTasksApplication(unittest.TestCase): def setUp(self): self.tmpdir = tempfile.mkdtemp() @@ -128,6 +128,7 @@ def test_layout_load_pickle_protocol_3(self): self.assertEqual(state.previous_window_layouts[0].size, (492, 743)) def test_gui_needs_GUI_instance(self): - with self.assertRaises(TraitError): - app = TasksApplication() - app.gui = DummyGUI() + # Trivial test where we simply set the trait + # and the test passes because no errors are raised. + app = TasksApplication() + app.gui = DummyGUI() From 7f7af8858cb94e8a32002064480f0f2426ffc361 Mon Sep 17 00:00:00 2001 From: Sai Rahul Poruri Date: Fri, 28 Aug 2020 12:47:20 +0100 Subject: [PATCH 3/5] FIX : Readd removed unittest skip decorator and remove an unused import modified: envisage/ui/tasks/tests/test_tasks_application.py --- envisage/ui/tasks/tests/test_tasks_application.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/envisage/ui/tasks/tests/test_tasks_application.py b/envisage/ui/tasks/tests/test_tasks_application.py index a9c59cffe..7ec5d1e83 100644 --- a/envisage/ui/tasks/tests/test_tasks_application.py +++ b/envisage/ui/tasks/tests/test_tasks_application.py @@ -19,7 +19,7 @@ from envisage.ui.tasks.api import TasksApplication from envisage.ui.tasks.tasks_application import DEFAULT_STATE_FILENAME from pyface.i_gui import IGUI -from traits.api import HasTraits, provides, TraitError +from traits.api import HasTraits, provides requires_gui = unittest.skipIf( os.environ.get("ETS_TOOLKIT", "none") in {"null", "none"}, @@ -32,7 +32,7 @@ class DummyGUI(HasTraits): pass - +@requires_gui class TestTasksApplication(unittest.TestCase): def setUp(self): self.tmpdir = tempfile.mkdtemp() From 35785bf5751de0fec6c66b57a392e8c6d73c4c0d Mon Sep 17 00:00:00 2001 From: Sai Rahul Poruri Date: Fri, 28 Aug 2020 12:49:22 +0100 Subject: [PATCH 4/5] CLN : Update test method name modified: envisage/ui/tasks/tests/test_tasks_application.py --- envisage/ui/tasks/tests/test_tasks_application.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/envisage/ui/tasks/tests/test_tasks_application.py b/envisage/ui/tasks/tests/test_tasks_application.py index 7ec5d1e83..4c4d554a3 100644 --- a/envisage/ui/tasks/tests/test_tasks_application.py +++ b/envisage/ui/tasks/tests/test_tasks_application.py @@ -127,7 +127,7 @@ def test_layout_load_pickle_protocol_3(self): state = app._state self.assertEqual(state.previous_window_layouts[0].size, (492, 743)) - def test_gui_needs_GUI_instance(self): + 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. app = TasksApplication() From 2486fed27627702905a2629c757e0344bf351623 Mon Sep 17 00:00:00 2001 From: Poruri Sai Rahul Date: Tue, 1 Sep 2020 08:02:53 +0000 Subject: [PATCH 5/5] REF : Use Instance, not Supports for gui trait --- envisage/ui/tasks/tasks_application.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/envisage/ui/tasks/tasks_application.py b/envisage/ui/tasks/tasks_application.py index 034c6d966..34b9f91be 100644 --- a/envisage/ui/tasks/tasks_application.py +++ b/envisage/ui/tasks/tasks_application.py @@ -24,7 +24,6 @@ Int, List, Str, - Supports, Vetoable, ) from traits.etsconfig.api import ETSConfig @@ -61,7 +60,7 @@ class TasksApplication(Application): active_window = Instance("envisage.ui.tasks.task_window.TaskWindow") # The Pyface GUI for the application. - gui = Supports("pyface.i_gui.IGUI") + gui = Instance("pyface.i_gui.IGUI") # Icon for the whole application. Will be used to override all taskWindows # icons to have the same.