Exemplo n.º 1
0
 def test_read_abspath(self):
     history.append('fred')
     history.append('wilma')
     history.write_file('my_history', raise_exc=True)
     history.clear()
     history.read_file(abspath('my_history'), raise_exc=True)
     self.assertEqual(len(history), 2)
Exemplo n.º 2
0
 def test_read_bytes_name(self):
     history.append('fred')
     history.append('wilma')
     history.write_file(bytes('my_history', sys.getfilesystemencoding()), raise_exc=True)
     history.clear()
     history.read_file(bytes('my_history', sys.getfilesystemencoding()), raise_exc=True)
     self.assertEqual(len(history), 2)
Exemplo n.º 3
0
 def test_read_tilde_expanded(self):
     history.append('fred')
     history.append('wilma')
     history.write_file(self.histfile, raise_exc=True)
     history.clear()
     history.read_file('~/.history', raise_exc=True)
     self.assertEqual(len(history), 2)
Exemplo n.º 4
0
 def test_read_tilde_expanded(self):
     history.append('fred')
     history.append('wilma')
     history.write_file(self.histfile, raise_exc=True)
     history.clear()
     history.read_file('~/.history', raise_exc=True)
     self.assertEqual(len(history), 2)
Exemplo n.º 5
0
 def test_read_abspath(self):
     history.append('fred')
     history.append('wilma')
     history.write_file('my_history', raise_exc=True)
     history.clear()
     history.read_file(abspath('my_history'), raise_exc=True)
     self.assertEqual(len(history), 2)
Exemplo n.º 6
0
 def test_read_None_name(self):
     history.append('fred')
     history.append('wilma')
     history.write_file(self.histfile, raise_exc=True)
     history.clear()
     history.read_file(None, raise_exc=True)
     self.assertEqual(len(history), 2)
Exemplo n.º 7
0
 def test_read_None_name(self):
     history.append('fred')
     history.append('wilma')
     history.write_file(self.histfile, raise_exc=True)
     history.clear()
     history.read_file(None, raise_exc=True)
     self.assertEqual(len(history), 2)
Exemplo n.º 8
0
 def test_append_relative(self):
     history.write_file('my_history', raise_exc=True)
     history.append('fred')
     history.append('wilma')
     history.append_file(2, 'my_history')
     history.clear()
     history.read_file('my_history', raise_exc=True)
     self.assertEqual(len(history), 2)
Exemplo n.º 9
0
 def test_read_bytes_name(self):
     history.append('fred')
     history.append('wilma')
     history.write_file(bytes('my_history',
                              sys.getfilesystemencoding()),
                        raise_exc=True)
     history.clear()
     history.read_file(bytes('my_history', sys.getfilesystemencoding()),
                       raise_exc=True)
     self.assertEqual(len(history), 2)
Exemplo n.º 10
0
 def test_write_file_truncates_file(self):
     history.append('fred')
     history.append('wilma')
     history.append('pebbles')
     history.max_file = 2
     history.write_file('my_history', raise_exc=True)
     history.clear()
     history.read_file('my_history', raise_exc=True)
     self.assertEqual(len(history), 2)
     self.assertEqual(history[0], 'wilma')
     self.assertEqual(history[1], 'pebbles')
Exemplo n.º 11
0
 def test_write_file_replaces_file(self):
     history.append('fred')
     history.append('wilma')
     history.write_file('my_history', raise_exc=True)
     history.clear()
     history.append('barney')
     history.append('betty')
     history.write_file('my_history', raise_exc=True)
     history.clear()
     history.read_file('my_history', raise_exc=True)
     self.assertEqual(len(history), 2)
     self.assertEqual(history[0], 'barney')
     self.assertEqual(history[1], 'betty')
Exemplo n.º 12
0
 def test_write_file_replaces_file(self):
     history.append('fred')
     history.append('wilma')
     history.write_file('my_history', raise_exc=True)
     history.clear()
     history.append('barney')
     history.append('betty')
     history.write_file('my_history', raise_exc=True)
     history.clear()
     history.read_file('my_history', raise_exc=True)
     self.assertEqual(len(history), 2)
     self.assertEqual(history[0], 'barney')
     self.assertEqual(history[1], 'betty')
Exemplo n.º 13
0
 def test_append_file_truncates_file(self):
     history.append('fred')
     history.append('wilma')
     history.append('pebbles')
     history.write_file('my_history', raise_exc=True)
     history.clear()
     history.append('barney')
     history.append('betty')
     history.append('bammbamm')
     history.max_file = 3
     history.append_file(2, 'my_history')
     history.clear()
     history.read_file('my_history', raise_exc=True)
     self.assertEqual(len(history), 3)
     self.assertEqual(history[0], 'pebbles')
     self.assertEqual(history[1], 'betty')
     self.assertEqual(history[2], 'bammbamm')
Exemplo n.º 14
0
 def test_read_file_stifled(self):
     history.append('fred')
     history.append('wilma')
     history.append('barney')
     history.append('betty')
     history.append('pebbles')
     history.append('bammbamm')
     history.append('dino')
     self.assertEqual(len(history), 7)
     history.write_file('my_history', raise_exc=True)
     history.clear()
     history.max_entries = 5
     history.read_file('my_history', raise_exc=True)
     self.assertEqual(history[0], 'barney')
     self.assertEqual(history[1], 'betty')
     self.assertEqual(history[2], 'pebbles')
     self.assertEqual(history[3], 'bammbamm')
     self.assertEqual(history[4], 'dino')
     self.assertEqual(len(history), 5)
Exemplo n.º 15
0
 def test_read_file_stifled(self):
     history.append('fred')
     history.append('wilma')
     history.append('barney')
     history.append('betty')
     history.append('pebbles')
     history.append('bammbamm')
     history.append('dino')
     self.assertEqual(len(history), 7)
     history.write_file('my_history', raise_exc=True)
     history.clear()
     history.max_entries = 5
     history.read_file('my_history', raise_exc=True)
     self.assertEqual(history[0], 'barney')
     self.assertEqual(history[1], 'betty')
     self.assertEqual(history[2], 'pebbles')
     self.assertEqual(history[3], 'bammbamm')
     self.assertEqual(history[4], 'dino')
     self.assertEqual(len(history), 5)
Exemplo n.º 16
0
    def preloop(self):
        """Called when the :meth:`~kmd.Kmd.cmdloop` method is entered. Configures the
        readline completer and loads the history file.
        """
        if self.use_rawinput:
            history.max_entries = self.history_max_entries

            if self.history_file:
                history.read_file(self.history_file)

            if self.completekey:
                completer.reset()
                completer.quote_characters = QUOTE_CHARACTERS
                completer.word_break_characters = WORD_BREAK_CHARACTERS
                completer.filename_quote_characters = FILENAME_QUOTE_CHARACTERS
                completer.char_is_quoted_function = char_is_quoted
                completer.word_break_hook = self.word_break_hook
                completer.completer = self.complete
                completer.parse_and_bind(self.completekey+': complete')
Exemplo n.º 17
0
Arquivo: kmd.py Projeto: sim-pdf/kmd
    def preloop(self):
        """Called when the :meth:`~kmd.Kmd.cmdloop` method is entered. Configures the
        readline completer and loads the history file.
        """
        if self.use_rawinput:
            if self.history_max_entries >= 0:
                history.max_entries = self.history_max_entries

            if self.history_file:
                history.read_file(self.history_file)

            if self.completekey:
                self.clear_hooks()
                completer.quote_characters = QUOTE_CHARACTERS
                completer.word_break_characters = WORD_BREAK_CHARACTERS
                completer.special_prefixes = ''
                completer.filename_quote_characters = FILENAME_QUOTE_CHARACTERS
                completer.word_break_hook = self.word_break_hook
                completer.char_is_quoted_function = char_is_quoted
                completer.completer = self.complete
                completer.parse_and_bind(self.completekey+': complete')