def test_get_history_item(self):
        readline.add_history('test get history item')
        length = readline.get_current_history_length()
        item = readline.get_history_item(length)
        self.assertEqual(item, 'test get history item')

        item = readline.get_history_item(length + 1)
        self.assertIsNone(item)
    def test_remove_history_item(self):
        readline.add_history('test')
        length = readline.get_current_history_length()
        readline.remove_history_item(0)
        new_length = readline.get_current_history_length()
        self.assertEqual(new_length, length - 1)

        with self.assertRaises(ValueError):
            readline.remove_history_item(-1)
        with self.assertRaises(ValueError):
            readline.remove_history_item(length)
    def test_replace_history_item(self):
        readline.add_history('test replace history item 1')
        readline.replace_history_item(0, 'test replace history item 2')
        # replace is 0-based and get is 1-based
        item = readline.get_history_item(1)
        self.assertEqual(item, 'test replace history item 2')

        with self.assertRaises(ValueError):
            readline.replace_history_item(-1, 'test')
        with self.assertRaises(ValueError):
            readline.replace_history_item(0xffff, 'test')
 def test_add_history(self):
     readline.add_history('test')