예제 #1
0
 def test_should_put_backspace(self):
     input = TextInput(max_len=10)
     input.put('a')
     input.put('b')
     input.put(curses.KEY_BACKSPACE)
     self.assertEqual('a', input.text)
     self.assertEqual(1, input.cursor)
예제 #2
0
 def test_should_not_put_backspace_at_beginning(self):
     input = TextInput(max_len=10)
     input.put('a')
     input.put(curses.KEY_LEFT)
     input.put(curses.KEY_BACKSPACE)
     self.assertEqual('a', input.text)
     self.assertEqual(0, input.cursor)
예제 #3
0
 def test_should_put_char_at_beginning(self):
     input = TextInput(max_len=10)
     input.put('a')
     input.put(curses.KEY_LEFT)
     input.put('b')
     self.assertEqual('ba', input.text)
     self.assertEqual(1, input.cursor)
예제 #4
0
 def test_should_go_to_end(self):
     input = TextInput(max_len=10)
     input.put('a')
     input.put('b')
     input.put(curses.KEY_HOME)
     input.put(curses.KEY_END)
     self.assertEqual(2, input.cursor)
예제 #5
0
 def test_should_put_backspace_before_end(self):
     input = TextInput(max_len=10)
     input.put('a')
     input.put('b')
     input.put(curses.KEY_LEFT)
     input.put(curses.KEY_BACKSPACE)
     self.assertEqual('b', input.text)
     self.assertEqual(0, input.cursor)
예제 #6
0
 def test_should_delete_char_at_cursor(self):
     input = TextInput(max_len=10)
     input.put('a')
     input.put('b')
     input.put(curses.KEY_LEFT)
     input.put(curses.KEY_LEFT)
     input.put(curses.KEY_DC)
     self.assertEqual('b', input.text)
     self.assertEqual(0, input.cursor)
예제 #7
0
 def test_should_squeeze_text_input_after_input(self):
     input = TextInput(max_len=10)
     input.put('a')
     input.put('b')
     input.put('c')
     input.put('d')
     input.width = 3
     self.assertEqual('cd', input.visible_text)
     self.assertEqual(2, input.cursor)
예제 #8
0
 def test_should_scroll_narrow_input(self):
     input = TextInput(max_len=10)
     input.width = 3
     input.put('a')
     input.put('b')
     input.put('c')
     self.assertEqual('abc', input.text)
     self.assertEqual('bc', input.visible_text)
     self.assertEqual(2, input.cursor)
예제 #9
0
 def test_should_initialize_text_input(self):
     input = TextInput(max_len=10)
     self.assertEqual('', input.text)
     self.assertEqual('', input.visible_text)
     self.assertEqual(0, input.cursor)
예제 #10
0
 def test_should_not_move_cursor_after_right_boundary(self):
     input = TextInput(max_len=10)
     input.put('a')
     input.put(curses.KEY_RIGHT)
     self.assertEqual(1, input.cursor)
예제 #11
0
 def test_should_honor_max_len(self):
     input = TextInput(max_len=10)
     for c in range(11):
         input.put(chr(ord('a') + c))
     self.assertEqual('abcdefghij', input.text)
     self.assertEqual(10, input.cursor)
예제 #12
0
 def test_should_move_cursor_right(self):
     input = TextInput(max_len=10)
     input.put('a')
     input.put(curses.KEY_LEFT)
     input.put(curses.KEY_RIGHT)
     self.assertEqual(1, input.cursor)
예제 #13
0
 def test_should_swallow_control_chars(self):
     input = TextInput(max_len=10)
     input.put('\t')
     self.assertEqual('', input.text)
     self.assertEqual(0, input.cursor)
예제 #14
0
 def test_should_initialize_text_input_with_long_text(self):
     input = TextInput(max_len=10, text='an excessively long test')
     self.assertEqual('an excessi', input.visible_text)
     self.assertEqual(10, input.cursor)
예제 #15
0
 def test_should_initialize_text_input_with_text(self):
     input = TextInput(max_len=10, text='test')
     self.assertEqual('test', input.visible_text)
     self.assertEqual(4, input.cursor)
예제 #16
0
 def test_should_put_single_char(self):
     input = TextInput(max_len=10)
     input.put('a')
     self.assertEqual('a', input.text)
     self.assertEqual('a', input.visible_text)
     self.assertEqual(1, input.cursor)
예제 #17
0
 def test_should_go_to_beginning(self):
     input = TextInput(max_len=10)
     input.put('a')
     input.put('b')
     input.put(curses.KEY_HOME)
     self.assertEqual(0, input.cursor)
예제 #18
0
 def test_should_not_move_cursor_before_left_boundary(self):
     input = TextInput(max_len=10)
     input.put('a')
     input.put(curses.KEY_LEFT)
     input.put(curses.KEY_LEFT)
     self.assertEqual(0, input.cursor)