Commits

Ronny Pfannschmidt  committed aae337b

clean up and simplify view tests

  • Participants
  • Parent commits 3ecd95e

Comments (0)

Files changed (1)

File tests/ui/test_views.py

 
 class TestView(PidaView):
 
-    gladefile = 'test_view'
+    builder_file = 'test_view'
+    clicked = False
+    def on_b1__clicked(self, button):
+        self.clicked = True
 
-    def on_b1__clicked(self, button):
-        self.svc._clicked = True
+def pytest_funcarg__view(request):
+    view = TestView(None)
+    refresh_gui()
+    return view
 
-class ActionView(PidaView):
 
-    gladefile = 'test_view'
+def test_has_toplevel(view):
+    assert view.get_toplevel() is not None
 
-    def on_test_act__activate(self, action):
-        self.svc._clicked = True
+def test_has_no_parent(view):
+    assert view.get_toplevel().get_parent() is None
 
-    def on_b2__clicked(self, button):
-        self.svc._clicked = True
+def test_event_callback(view):
+    assert not view.clicked
+    view.b1.clicked()
+    refresh_gui()
+    assert view.clicked
 
-class BasicViewTest(TestCase):
-
-    def setUp(self):
-        self._v = TestView(self)
-        refresh_gui()
-
-    def test_has_toplevel(self):
-        self.assertNotEqual(self._v.get_toplevel(), None)
-
-    def test_has_no_parent(self):
-        self.assertEqual(self._v.get_toplevel().get_parent(), None)
-
-
-class ViewCallbackTest(TestCase):
-
-    def setUp(self):
-        self._v = TestView(self)
-        self._clicked = False
-        refresh_gui()
-
-    def test_event_callback(self):
-        self.assertEqual(self._clicked, False)
-        self._v.b1.clicked()
-        refresh_gui()
-        self.assertEqual(self._clicked, True)
-
-
-class ViewActionsTest(TestCase):
-
-    def setUp(self):
-        self._v = TestView(self)
-        self._clicked = False
-        refresh_gui()
-
-    def test_actions(self):
-        self.assertEqual(self._clicked, False)
-        self._v.test_act.activate()
-
+def test_actions(view):
+    assert not view.clicked
+    view.test_act.activate()