Пример #1
0
 def test_render(self):
     self.assertEqual(
         render_to_content(self.widget._w.contents["body"][0], (7, 2)),
         render_widgets_to_content([
             urwid.AttrMap(urwid.Text("Title"), "view-title"),
             urwid.AttrMap(urwid.Text("view1"), "view-item")
         ], (7, 2))
     )
Пример #2
0
 def test_render(self):
     widget = Tabs(["view1", "view2", "view3"], 0)
     self.assertEqual(
         render_to_content(widget, (15,)),
         render_widgets_to_content([
             urwid.AttrMap(urwid.Text("view1"), "tabs focus"),
             urwid.AttrMap(urwid.Text("view2"), "tabs"),
             urwid.AttrMap(urwid.Text("view3"), "tabs")
         ], (15,), inline=True)
     )
Пример #3
0
    def test_search(self):
        self.widget.search_widget.keypress((4,), "v")
        self.widget.search_widget.keypress((4,), "i")
        self.widget.search_widget.keypress((4,), "e")
        self.widget.search_widget.keypress((4,), "w")
        self.widget.search_widget.keypress((4,), "enter")

        match = render_widgets_to_content(
            [urwid.Text(("view-title", "Title")),
             urwid.Text([("match", "view"), ("view-item", "1")])],
            (5, 3)
        )
        no_match = render_widgets_to_content(
            [urwid.Text(("view-title", "Title")),
             urwid.Text(("view-item", "view1"))],
            (5, 3)
        )

        self.assertEqual(
            render_to_content(self.widget.content_widget, (5, 3)),
            match)

        self.widget.keypress((0,), "n")
        self.assertEqual(
            render_to_content(self.widget.content_widget, (5, 3)),
            no_match)

        self.widget.keypress((0,), "N")
        self.assertEqual(
            render_to_content(self.widget.content_widget, (5, 3)),
            match)

        self.widget.keypress((0,), "N")
        self.assertEqual(
            render_to_content(self.widget.content_widget, (5, 3)),
            no_match)