示例#1
0
    def test_left_and_right_keys(self):
        fake_stdin = io.StringIO("la" + LEFT + "b" + RIGHT + RIGHT + "n" +
                                 ENTER)
        with Autocomplete(self.fake_stdout, fake_stdin, self.completer) as ac:
            response = ac.input("? ")

        self.assertEqual(response, "lban")
示例#2
0
    def test_home_key(self):
        fake_stdin = io.StringIO("lb" + HOME + "a" + DOWN + ENTER)
        with Autocomplete(self.fake_stdout, fake_stdin, self.completer) as ac:
            response = ac.input("? ")

        self.assertEqual(response, "albania")
示例#3
0
    def test_press_up_without_selection(self):
        fake_stdin = io.StringIO("na" + UP + UP + ENTER)
        with Autocomplete(self.fake_stdout, fake_stdin, self.completer) as ac:
            response = ac.input("? ")

        self.assertEqual(response, "na")
示例#4
0
    def test_select_then_unselect(self):
        fake_stdin = io.StringIO("na" + DOWN + DOWN + UP + UP + ENTER)
        with Autocomplete(self.fake_stdout, fake_stdin, self.completer) as ac:
            response = ac.input("? ")

        self.assertEqual(response, "na")
示例#5
0
    def test_press_key_with_selection(self):
        fake_stdin = io.StringIO("za" + DOWN + "s" + ENTER)
        with Autocomplete(self.fake_stdout, fake_stdin, self.completer) as ac:
            response = ac.input("? ")

        self.assertEqual(response, "zambias")
示例#6
0
    def test_backspace_with_selection(self):
        fake_stdin = io.StringIO("za" + DOWN + BACKSPACE + ENTER)
        with Autocomplete(self.fake_stdout, fake_stdin, self.completer) as ac:
            response = ac.input("? ")

        self.assertEqual(response, "zambi")
示例#7
0
    def test_backspace(self):
        fake_stdin = io.StringIO("a" + BACKSPACE + "b" + ENTER)
        with Autocomplete(self.fake_stdout, fake_stdin, self.completer) as ac:
            response = ac.input("? ")

        self.assertEqual(response, "b")
示例#8
0
    def test_force_selection_with_no_input(self):
        fake_stdin = io.StringIO(DOWN + DOWN + DOWN + ENTER)
        with Autocomplete(self.fake_stdout, fake_stdin, self.completer) as ac:
            response = ac.input("? ")

        self.assertEqual(response, "brazil")
示例#9
0
    def test_down_key_with_no_selection(self):
        fake_stdin = io.StringIO("leb" + DOWN + ENTER)
        with Autocomplete(self.fake_stdout, fake_stdin, self.completer) as ac:
            response = ac.input("? ")

        self.assertEqual(response, "leb")
示例#10
0
    def test_select_from_multiple_options(self):
        fake_stdin = io.StringIO("na" + DOWN + DOWN + ENTER)
        with Autocomplete(self.fake_stdout, fake_stdin, self.completer) as ac:
            response = ac.input("? ")

        self.assertEqual(response, "nauru")
示例#11
0
    def test_simple_input(self):
        fake_stdin = io.StringIO("abc" + ENTER)
        with Autocomplete(self.fake_stdout, fake_stdin, self.completer) as ac:
            response = ac.input("? ")

        self.assertEqual(response, "abc")
示例#12
0
    def test_tab_to_select(self):
        fake_stdin = io.StringIO("na" + TAB + DOWN + ENTER)
        with Autocomplete(self.fake_stdout, fake_stdin, self.completer) as ac:
            response = ac.input("? ")

        self.assertEqual(response, "namibia")
示例#13
0
    def test_handle_backspace_in_middle_of_word(self):
        fake_stdin = io.StringIO("lorim" + LEFT + BACKSPACE + "e" + ENTER)
        with Autocomplete(self.fake_stdout, fake_stdin, self.completer) as ac:
            response = ac.input("? ")

        self.assertEqual(response, "lorem")