Permalink
Browse files

fixes issue #87

  • Loading branch information...
1 parent a104f36 commit 9de0346c93f63e821e091b90841c593b7f68e5f6 @itziakos itziakos committed May 31, 2013
Showing with 38 additions and 2 deletions.
  1. +3 −2 pyface/tasks/task_layout.py
  2. +35 −0 pyface/tasks/tests/test_task_layout.py
@@ -3,7 +3,7 @@
import sys
# Enthought library imports.
-from traits.api import Either, Enum, HasStrictTraits, Int, List, Str, This
+from traits.api import Either, Enum, HasStrictTraits, Int, Instance, List, Str, This
class LayoutItem(HasStrictTraits):
@@ -132,7 +132,8 @@ class Splitter(LayoutContainer):
# The sub-items of the splitter, which are PaneItems, Tabbed layouts, and
# other Splitters.
- items = List(Either(PaneItem, Tabbed, This), pretty_skip=True)
+ items = List(Either(PaneItem, Tabbed,
+ Instance('pyface.tasks.api.Splitter')), pretty_skip=True)
class HSplitter(Splitter):
""" A convenience class for horizontal splitters.
@@ -0,0 +1,35 @@
+# Standard library imports.
+import unittest
+
+# Enthought library imports.
+from pyface.tasks.api import HSplitter, PaneItem, Tabbed, VSplitter
+
+
+class LayoutItemsTestCase(unittest.TestCase):
+ """ Testing that the layout types play nice with each other.
+
+ This is a regression test for issue #87
+ (https://github.com/enthought/pyface/issues/87)
+
+ """
+
+ def setUp(self):
+ self.items = [HSplitter(), PaneItem(), Tabbed(), VSplitter()]
+
+ def test_hsplitter_items(self):
+ layout = HSplitter(*self.items)
+ self.assertEqual(layout.items, self.items)
+
+ def test_tabbed_items(self):
+ # Tabbed items only accept PaneItems
+ items = [PaneItem(), PaneItem()]
+ layout = Tabbed(*items)
+ self.assertEqual(layout.items, items)
+
+ def test_vsplitter_items(self):
+ layout = VSplitter(*self.items)
+ self.assertEqual(layout.items, self.items)
+
+
+if __name__ == '__main__':
+ unittest.main()

0 comments on commit 9de0346

Please sign in to comment.