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_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')