Пример #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)
Пример #2
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)
Пример #3
0
 def test_write_bytes_name(self):
     history.append('fred')
     history.append('wilma')
     history.write_file(bytes('my_history',
                              sys.getfilesystemencoding()),
                        raise_exc=True)
     self.assertTrue(isfile('my_history'))
Пример #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)
Пример #5
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)
Пример #6
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)
Пример #7
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)
Пример #8
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)
Пример #9
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)
Пример #10
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)
Пример #11
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')
Пример #12
0
    def postloop(self):
        """Called when the :meth:`~kmd.Kmd.cmdloop` method is exited. Resets the readline
        completer and saves the history file.
        Note that :meth:`~kmd.Kmd.postloop` is called even if :meth:`~kmd.Kmd.cmdloop`
        exits with an exception!
        """
        if self.use_rawinput:
            if self.history_file:
                history.write_file(self.history_file)

            if self.completekey:
                completer.reset()
Пример #13
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')
Пример #14
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')
Пример #15
0
Файл: kmd.py Проект: sim-pdf/kmd
    def postloop(self):
        """Called when the :meth:`~kmd.Kmd.cmdloop` method is exited. Resets the readline
        completer and saves the history file.
        Note that :meth:`~kmd.Kmd.postloop` is called even if :meth:`~kmd.Kmd.cmdloop`
        exits with an exception!
        """
        if self.use_rawinput:
            if self.history_file:
                history.write_file(self.history_file)

            if self.completekey:
                self.clear_hooks()

            history.clear()
Пример #16
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')
Пример #17
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)
Пример #18
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)
Пример #19
0
 def test_write_abspath(self):
     history.append('fred')
     history.append('wilma')
     history.write_file(abspath('my_history'), raise_exc=True)
     self.assertTrue(isfile(abspath('my_history')))
     self.assertTrue(isfile('my_history'))
Пример #20
0
 def test_read_empty_string(self):
     history.append('fred')
     history.append('wilma')
     history.write_file(self.histfile, raise_exc=True)
     history.clear()
     self.assertRaises(IOError, history.read_file, '', raise_exc=True)
Пример #21
0
 def test_write_relative(self):
     history.append('fred')
     history.append('wilma')
     history.write_file('my_history', raise_exc=True)
     self.assertTrue(isfile('my_history'))
Пример #22
0
 def test_write_bytes_name(self):
     history.append('fred')
     history.append('wilma')
     history.write_file(bytes('my_history', sys.getfilesystemencoding()), raise_exc=True)
     self.assertTrue(isfile('my_history'))
Пример #23
0
 def test_write_tilde_expanded(self):
     history.append('fred')
     history.append('wilma')
     history.write_file('~/.history', raise_exc=True)
     self.assertTrue(isfile(self.histfile))
Пример #24
0
 def test_write_tilde_expanded(self):
     history.append('fred')
     history.append('wilma')
     history.write_file('~/.history', raise_exc=True)
     self.assertTrue(isfile(self.histfile))
Пример #25
0
 def test_write_None_name(self):
     history.append('fred')
     history.append('wilma')
     history.write_file(None, raise_exc=True)
     self.assertTrue(isfile(self.histfile))
Пример #26
0
 def test_write_None_name(self):
     history.append('fred')
     history.append('wilma')
     history.write_file(None, raise_exc=True)
     self.assertTrue(isfile(self.histfile))
Пример #27
0
 def test_write_relative(self):
     history.append('fred')
     history.append('wilma')
     history.write_file('my_history', raise_exc=True)
     self.assertTrue(isfile('my_history'))
Пример #28
0
 def test_read_empty_string(self):
     history.append('fred')
     history.append('wilma')
     history.write_file(self.histfile, raise_exc=True)
     history.clear()
     self.assertRaises(IOError, history.read_file, '', raise_exc=True)
Пример #29
0
 def test_write_abspath(self):
     history.append('fred')
     history.append('wilma')
     history.write_file(abspath('my_history'), raise_exc=True)
     self.assertTrue(isfile(abspath('my_history')))
     self.assertTrue(isfile('my_history'))